How to Add space at the end of each line in linux

hi,.
I am writing a small script in csh...
Can any one tel me how to add space at end of each line in a file

$ awk '{print $0" "}' inputfile
1 Like
 
sed 's/.*/& /' input
1 Like
 
sed 's/$/ /g' input
1 Like

No need for the global flag, since there's only one end of line per line.

sed 's/$/ /' input

Regards,
Alister

1 Like

true ... just wrote out of habit :slight_smile:

1 Like

thank u all ... but these are not working

I have a file called projects
the contents are
project1
project2
project3
project4

After each and every line i should append space
the contents should be like
project1"space"
project2"space"
project3"space"
project4"space"

can u all help me out in this

did u redirect the output ?

eg :

 
$ awk '{print $0" "}' inputfile > outputfile
$ sed 's/.*/& /' input > outputfile
$ sed 's/$/ /g' input > outputfile

or if your sed supports the -i option, then try

 
sed -i 's/$/ /' input

u want space as in ' ' or the word space

if its word space then

 
sed 's/$/"space"/' input

To edit the file in place:

ed -s project <<'EOED'
1,$s/$/ /
w
q
EOED

Regards,
Alister