LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Steps needed to convert multiple text files into one master text file (http://www.linuxquestions.org/questions/programming-9/steps-needed-to-convert-multiple-text-files-into-one-master-text-file-590124/)

jamtech 10-07-2007 05:24 PM

Steps needed to convert multiple text files into one master text file
 
Hello all

I would like to know what process would be best to convert multiple text files into one master text file?

I have complied many word list text files with in one directory see screen shot below.

I would like to take the files in the assigned directory and convert them into on master word list text file.

Would it be best to have a Bash or Perl script handle the process?

By the way I am willing to share any of the files listed in the screen shot just reply to this post requesting what file you want.

Thanks in advance

Screen shot link:http://dontburnmybeans.blogspot.com/

GrapefruiTgirl 10-07-2007 05:29 PM

A simple loop in BASH would combine some text files..

Like

For I in /path/to/file/folder/*; do
cat $I >> /path/to/master/file
done


and presto, all the files are added into one big file.
Is this what you want?

ntubski 10-07-2007 08:12 PM

You could even get away with no loop at all:
Code:

cat /path/to/files/*.txt > /path/to/master/file

GrapefruiTgirl 10-07-2007 08:39 PM

cat them all >> all them cats
 
Quote:

Originally Posted by ntubski (Post 2916700)
You could even get away with no loop at all:
Code:

cat /path/to/files/*.txt > /path/to/master/file

:) Well how 'bout THAT! Thanks for the tip, ntubski! If I'd only known... But then again, there'd be nothing to do..

chrism01 10-07-2007 11:00 PM

You might want to pipe through 'sort -u' to strip out duplicates (if you have any) eg

cat /path/to/files/*.txt | sort -u > /path/to/master/file

jamtech 10-07-2007 11:24 PM

Thank you so very much for both of your solutions


All times are GMT -5. The time now is 05:24 AM.