User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,423 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,615 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 708 | Replies: 2
Reply
Join Date: Mar 2007
Posts: 1
Reputation: maxcell is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
maxcell maxcell is offline Offline
Newbie Poster

Text

  #1  
Mar 27th, 2007
Hello,
I'm still new to linux, and im looking for some helpful ideas.
What I'm trying to do is I need to write a script that will take a text file, which has paragraphs and create another text file which extracts every individual word from that orignal text file and lists them line by line..

example:

text file 1:
hello. this is a test example file! i hope i could get some great ideas...

new text file2:
hello
this
is
a
test
example
file
i
...


and so on...

Any ideas on i how i might go about accomplishing this?

thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: Bellevue, WA
Posts: 1,548
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Rep Power: 8
Solved Threads: 51
Sponsor
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: Text

  #2  
Mar 27th, 2007
without removing duplicates, you could just replace any spaces with a newline:
sed "s/ /\n/g" originalFile > outputFile
This won't remove punctuation, but you could write another one to do that.

*code not tested, but pretty sure it'll do the trick
Reply With Quote  
Join Date: Apr 2006
Posts: 140
Reputation: ghostdog74 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 26
ghostdog74 ghostdog74 is offline Offline
Junior Poster

Re: Text

  #3  
Apr 2nd, 2007
 tr ' ' '\n' <file > newfile
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC