PDA

View Full Version : Concatenating Multiple Files



Jexel
March 16th, 2008, 10:17 AM
Hi there,

Basically I've dumped all my SMS's from my phone onto my computer. I'm trying to write a command that will concatenate all the sms's from one specific number into one file.

The command:

grep -l +xxxxxxxxxxx sms*


Gives all the filenames of the files which contain the particular phone number. How can I then pipe this into another command that will read the file and pipe it into another file?

ghostdog74
March 16th, 2008, 10:29 AM
Hi there,

Basically I've dumped all my SMS's from my phone onto my computer. I'm trying to write a command that will concatenate all the sms's from one specific number into one file.

The command:

grep -l +xxxxxxxxxxx sms*


Gives all the filenames of the files which contain the particular phone number. How can I then pipe this into another command that will read the file and pipe it into another file?

try



grep -l +xxxxxxxxxxx sms* | while read -r FILE
do
# do processing on file $FILE
done

Jexel
March 16th, 2008, 10:37 AM
that did the trick. Thanks a lot!

supirman
March 16th, 2008, 01:35 PM
Or you could have just:


cat `grep -l +xxxxxxxxxxx sms*` > xxxxxxxxxxx.txt

ghostdog74
March 16th, 2008, 02:20 PM
Or you could have just:


cat `grep -l +xxxxxxxxxxx sms*` > xxxxxxxxxxx.txt
Not if there are customized processing needed to be done on each line of those files found

supirman
March 16th, 2008, 03:15 PM
Not if there are customized processing needed to be done on each line of those files found

OP said he wanted to concatenate multiple files. There was no implication of special processing requirements per file...