943,749 Members | Top Members by Rank

Ad:
Jun 8th, 2007
0

Concat files with similar names in different directories

Expand Post »
Dear Experts,

to give a better picture i will explain the directory structure first

the files have the same naming convention and the only difference is the first letters which is the title of that account, there is a total of 210 files only the bold letters change for each file
exe: file 1,
/Data/KG-02/ACT/KG-02-PEF-RHOX-NOR.dat
file 2
/Data/KG-64/ACT/KG-64-PEF-RHOX-NOR.dat

+>Data
-----> /KG-02
-------->/ACT/
-------->KG-02-PEF-RHOX-NOR.dat
i have to concatinate these file with all the other files of similar name in the different directories, so i can have one account summary.

id appreciate any help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
slbit is offline Offline
7 posts
since Jun 2007
Jun 10th, 2007
0

Re: Concat files with similar names in different directories

Shell Scripting Syntax (Toggle Plain Text)
  1. for i in Data/KG-*;do cat "$i"/ACT/*dat>"${i##*/}.dat";done
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
radoulov is offline Offline
54 posts
since Feb 2007
Jun 11th, 2007
0

Re: Concat files with similar names in different directories

thanks, but i got an error message declaring illegal variable name
Click to Expand / Collapse  Quote originally posted by radoulov ...
Shell Scripting Syntax (Toggle Plain Text)
  1. for i in Data/KG-*;do cat "$i"/ACT/*dat>"${i##*/}.dat";done
Reputation Points: 10
Solved Threads: 0
Newbie Poster
slbit is offline Offline
7 posts
since Jun 2007
Jun 11th, 2007
0

Re: Concat files with similar names in different directories

You're using a very old shell, try with a different one: bash, ksh, zsh (for example, do not use /usr/bin/sh on Solaris).
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
radoulov is offline Offline
54 posts
since Feb 2007
Jun 12th, 2007
0

Re: Concat files with similar names in different directories

Works Perfectly ,, Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
slbit is offline Offline
7 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: shell script
Next Thread in Shell Scripting Forum Timeline: Reading through lines of text file sequencially





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC