Add white space to the end of a line with sed

Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end.

thanks

Karl

 sed 's/$/     /' filename > newfilename
1 Like

one more thing..

is the $ the last character of a line or the space just after the last character..

I thought i had tried that and it replaced the last string on each line with the 5 spaces. I could be wrong

thanks again for the help

karl

The '$' is not a physical character, but a representation of end of line.

Similar for '^' that represents the start of the line.

'$' designates the 'end of line'.
doing 'man regexp' yields:

     4.2   A dollar sign ($) at the end  of  an  entire  RE  con-
           strains that RE to match a final segment of a line.

Adding to this post I just wanted to know how to add some characters other than special characters in every line of a file , say I want to add a "/" at the end of all lines in file. Kindly help. Thank you

Escape the character with a backslash:

sed 's/$/\//'

Regards

Thanks