Delete newlines after every one space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete newlines after every one space
# 1  
Old 10-12-2011
Delete newlines after every one space

Hi All,

I have a file which looks like this:

Code:
abc 3456
computer 3214
printer 0.9823
computer 3214

Can anyone please let me know how I can format my text like this?

Code:
abc 3456 computer 3214 printer 0.9823 computer 3214

I know how to space to newlines using tr but don't know how to do it after leaving one space.

I am using Linux.
# 2  
Old 10-12-2011
Code:
$ xargs < infile

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 10-12-2011
Or:

Code:
paste -sd\  infile

This User Gave Thanks to radoulov For This Post:
# 4  
Old 10-12-2011
Code:
awk '{ORS=" ";print}' input


Last edited by radoulov; 10-12-2011 at 08:15 AM.. Reason: Code tags!
This User Gave Thanks to ltomuno For This Post:
# 5  
Old 10-12-2011
Quote:
Originally Posted by ltomuno
awk '{ORS=" ";print}' input
A small modification Smilie

Code:
awk 'ORS=" "' input_file

--ahamed
This User Gave Thanks to ahamed101 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Not delete space blank

Hi everyone, i need to "grep" a file with a string with space blanks, like this: grep "XXXX XX" file.txt The problem, i need put the "XXXX XX" in a string variable. When the script executes the grep, do: gresp XXXX XX file.txt How can i solve this problem? The... (5 Replies)
Discussion started by: Xedrox
5 Replies

2. Shell Programming and Scripting

Delete Space between last and first column

HI Input A R04 tion=1 Li 51599 R08 tiea=1 Li 51995 R11 ocatea=1 Li 51992 R12 nArea=1 Li ... (2 Replies)
Discussion started by: asavaliya
2 Replies

3. UNIX for Dummies Questions & Answers

Delete space

How to delete leading space of column 3? DEC 30 start test JAN 20 this is a test APR 10 hello test Must have: DEC 30 start test JAN 20 this is a test APR 10 hello test Thanks. (2 Replies)
Discussion started by: budz26
2 Replies

4. Shell Programming and Scripting

Converting space to newlines and renaming files

Hi All, I have this code which has two problems: find . -name '*.fil' | xargs while read page do cat $page | awk '{for(i=1;i<=NF;i++) print $i}' $page>$page.txt done find . -name '*.fil.txt' | xargs rename '.fil.txt' .fil 1. I am running this code in a directory consisting of large... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

Delete white space using sed

Hi , I have a file with contents as below group1 = aaaaa, bbbbb, ccccc, aaa group2=aaa, bbbbb, ccccc, aaaaa group3 = bbbbb, aaa, ccccc, aaaaa group4 = bbbbb, aaa,ccccc, aaaaa I want to search for "aaa" and the output should be as below group1 = aaaaa, bbbbb, ccccc group2= bbbbb, ccccc,... (3 Replies)
Discussion started by: anil8103
3 Replies

6. Shell Programming and Scripting

Delete all data before first space occurence

Hi Guyz, Can anyone help me in the following:- I want to delete all that is there in my file that occures before the first space comes. Eg. My file InputFile conatins the following: 123 12345678 87654 Hello 09867 09876654 34567 Happy I want the data occuring before the occurence... (3 Replies)
Discussion started by: DTechBuddy
3 Replies

7. Shell Programming and Scripting

Delete trailing white space

I have a string "disk0 with a trailing white space after it" but I want to get rid of this white space from right to left so that I am left with "disk0" only. Using sed 's/ $//g' doesn't seem to work Any ideas ? Thanks (5 Replies)
Discussion started by: cillmor
5 Replies

8. Shell Programming and Scripting

delete a single space in a line

hi i have a line like TL1330000000800 000DE9248737900 08000TS0231DE92 87379AMEX0000.T N 0080000000 00000. if there any single space between strings, i need to delete, if more than one keep the space as it is can some one help thanks Satya (1 Reply)
Discussion started by: Satyak
1 Replies

9. Shell Programming and Scripting

how to delete space character with sed

hi all, i want to delete a space character in word on unix script with command sed like : #dia n result: #dian is there anyone will help me ? regards, cahyo (1 Reply)
Discussion started by: cahyo3074
1 Replies

10. Shell Programming and Scripting

How to Delete space from the file

Hi, I want to delete the space from the file. For eg : deep | raj | sis i want the output as deep|raj|sis Please Help me Thanks, Deep (2 Replies)
Discussion started by: deepakpv
2 Replies
Login or Register to Ask a Question