The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cut last line of a word bullz26 Shell Programming and Scripting 2 03-18-2008 08:42 AM
Read line by line not word by word vadharah Shell Programming and Scripting 6 03-02-2008 11:29 AM
how to move word by word on command line pbsrinivas UNIX for Dummies Questions & Answers 1 11-23-2007 03:17 AM
Need to replace the first word of a line if it occurs again in the next line(shell) geeko Shell Programming and Scripting 1 09-25-2007 07:15 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 03:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-13-2006
Registered User
 

Join Date: Feb 2006
Posts: 65
put each word in new line - sed or tr

Hello !

I have a result of ls command in a file:

file1 file2 file3.out file4.pdf file5

they all are separated by space.

I need to put them on a separate line
example:
file1
file2
file3.out
file4.pdf
fil35

i tried
sed 's/ /\n/g' inputfile > outputfile
but did not help

also tried tr command but no result.

Please help.
thank you.
Reply With Quote
Forum Sponsor
  #2  
Old 09-13-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
tr should work. use this
Code:
tr ' ' '\n' < file
Reply With Quote
  #3  
Old 09-13-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
To add newline using SED use this

Code:
sed -f script file

script
################
s/ /\
/g
################
Reply With Quote
  #4  
Old 09-13-2006
Registered User
 

Join Date: Feb 2006
Posts: 65
Thank you

thank you.
that was very helpful.

Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0