LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-07-2007, 05:24 PM   #1
jamtech
LQ Newbie
 
Registered: May 2007
Distribution: Suse 10 and 11
Posts: 25

Rep: Reputation: 15
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/
 
Old 10-07-2007, 05:29 PM   #2
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
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?
 
Old 10-07-2007, 08:12 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,494

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
You could even get away with no loop at all:
Code:
 cat /path/to/files/*.txt > /path/to/master/file
 
Old 10-07-2007, 08:39 PM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
cat them all >> all them cats

Quote:
Originally Posted by ntubski View Post
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..
 
Old 10-07-2007, 11:00 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
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
 
Old 10-07-2007, 11:24 PM   #6
jamtech
LQ Newbie
 
Registered: May 2007
Distribution: Suse 10 and 11
Posts: 25

Original Poster
Rep: Reputation: 15
Thank you so very much for both of your solutions
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 11:42 AM
Application to convert MySQL files MYD, MYI, FRM to SQL text files ? SethShannon Linux - Newbie 1 09-28-2007 06:03 PM
need to convert text files into mysql database zafar466 Linux - Software 1 08-28-2007 12:53 AM
Utility Needed - list folder tree and files in text file Optiker Linux - Software 21 11-17-2006 02:46 PM
convert CSV (TEXT) files to UTF-16 cccc Programming 1 07-01-2004 01:54 AM


All times are GMT -5. The time now is 06:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration