DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   Concat files with similar names in different directories (http://www.daniweb.com/forums/thread80394.html)

slbit Jun 8th, 2007 5:20 am
Concat files with similar names in different directories
 
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

radoulov Jun 10th, 2007 9:46 am
Re: Concat files with similar names in different directories
 
for i in Data/KG-*;do cat "$i"/ACT/*dat>"${i##*/}.dat";done

slbit Jun 11th, 2007 1:15 am
Re: Concat files with similar names in different directories
 
thanks, but i got an error message declaring illegal variable name
Quote:

Originally Posted by radoulov (Post 385889)
for i in Data/KG-*;do cat "$i"/ACT/*dat>"${i##*/}.dat";done


radoulov Jun 11th, 2007 2:04 am
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).

slbit Jun 12th, 2007 2:52 am
Re: Concat files with similar names in different directories
 
Works Perfectly ,, Thanks


All times are GMT -4. The time now is 10:33 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC