Operating System - HP-UX
1830899 Members
3421 Online
110017 Solutions
New Discussion

Add space to end of each line of file.

 
SOLVED
Go to solution
Andy_126
Occasional Advisor

Add space to end of each line of file.

Hi all,

I need to add one single space to the end of each line in a text file. It seems there should be an easy way to do this with sed; my attempts thus far hve not worked.

Thanks if you are able to help.

Andy
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Add space to end of each line of file.

Probably about as easy as it gets is:
awk '{printf("%s \n",$0)}' < oldfile > newfile
If it ain't broke, I can fix that.
Tom Ward_1
Honored Contributor

Re: Add space to end of each line of file.

"sed 's/$/ /' file" should do it for you.
Andy_126
Occasional Advisor

Re: Add space to end of each line of file.

Thank you! Both work equally well!

Andy