put each word in new line - sed or tr


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting put each word in new line - sed or tr
# 1  
Old 09-13-2006
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.
# 2  
Old 09-13-2006
tr should work. use this
Code:
tr ' ' '\n' < file

# 3  
Old 09-13-2006
To add newline using SED use this

Code:
sed -f script file

script
################
s/ /\
/g
################

# 4  
Old 09-13-2006
Thank you

thank you.
that was very helpful.

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed for deleting the first word of each line?

sed /'1-2'/&^/ filename suppose there is a file containing three lines , how do we do delete the word from each line? hyter efr frf rerfer efe ewd cdcf evrfgf erfv the output has to look like frf ewd erfv (2 Replies)
Discussion started by: Rajeev Nukala
2 Replies

2. UNIX for Dummies Questions & Answers

How to delete a particular word on particular line with sed?

I have a file from which I am trying to delete a particular word on a particular line. NEW NEW /v/engine NEW /ifs/list NEW /ifs/vdrome NEW I am trying to delete the first line only if it contains the word NEW. I am also trying to delete the last line only if it contains the word NEW. I... (11 Replies)
Discussion started by: newbie2010
11 Replies

3. Shell Programming and Scripting

sed command to replace a word with new line and /

Hi, I have been trying to replace the key word "SQL> spool off " with "/ show errors" with out double quotes in all the files in a directory. above show erros should be displayed next line Could you please help me how to do that. I have tried something like this... (3 Replies)
Discussion started by: pointers
3 Replies

4. Shell Programming and Scripting

sed / awk to get specific word in line

I have http log that I want to get words after specific "tag", this a sample line from the log: 98,POST,200 OK,www.facebook.com,Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,/ajax/updatestatus.php?__a=1,datr=P_H1TgjTczCHxiGwdIF5tvpC; lu=Si1fMkcrU2SInpY8tk_7tAnw;... (6 Replies)
Discussion started by: erlanq
6 Replies

5. Shell Programming and Scripting

How to use sed to put string end of line?

I have several file as below, and i want to put .txt to specific text contain ^main=EXE^cmd=run script /usr/prog/bd_, file1 7.9102 12.1528 16.3672 7.4002 ^main=EXE^cmd=run script /usr/prog/bd_123^" line 16.3672 7.3134 17.8711 6.0981 file 2 7.9102 12.1528 16.3672 7.4002 ... (8 Replies)
Discussion started by: zulabc
8 Replies

6. Shell Programming and Scripting

Using sed to put text end of line

how to use sed to put .txt end of line..my input file below file1 make=^bak12^". DEV=LONG^cmd/usr/bak/ade4^" ..................................... file 2 make=^and_LONG/bak12^". DEV=LONG^cmd/usr/bak/ban3^" .......................................... file 3... (6 Replies)
Discussion started by: zulabc
6 Replies

7. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

8. Shell Programming and Scripting

sed - deleting each line up to a word

Hi there, I'd like to delete the beginning of a line up until it finds a certain word or character string: in this case, I'd like to delete each line up to the word "mounting". Thanks ;) Susan (12 Replies)
Discussion started by: kitykity
12 Replies

9. Shell Programming and Scripting

sed: break before word if it's not last on the line

I've been trying this, and can't get it right. I want to put a line break before a word, but only if it's *not* the last word in the line. So if the break work was "fish," then... We want to fish tomorrow ...would become... We want to fish tomorrow ...but this line would remain... (3 Replies)
Discussion started by: estebandido
3 Replies

10. Shell Programming and Scripting

SED to delete last word on line...what's wrong?

I have a line that gets pulled from a database that has a variable number of fields, fields can also be of a variable size. Each field has a variable number of spaces between them so there is no 'defined' delimiter. The LastData block is always a single word. What I want to do is delete the... (2 Replies)
Discussion started by: Bashingaway
2 Replies
Login or Register to Ask a Question