PDA

View Full Version : recursive concatenation


kerensa@unsw.ed
November 20th, 2008, 06:53 AM
Hi,

I have a problem with concatenation text files.

I have a directory, say 'foo'
Inside this folder, I have many sub folders, say 'oof1, oof2 .... oof20'

Each oof directory has a number of text files inside it. I need to
concatenate all the text files in oof directories within foo...

I know how concatenate files using textutil -cat, however I can't seem to
get this to go recursively up and down through the oof directories. Is there a way to do this? Or a better solution?

Thanks,

Kerensa.

macbri
November 20th, 2008, 07:28 AM
Hi Kerensa -

Try the following:

find /path/to/foo -type f -print | xargs cat > output.txt

One word of warning, don't put output.txt inside /path/to/foo or you'll keep appending it to itself until you run out of disk!