Bash: append text to last line of file

Rich picture Rich · Sep 7, 2010 · Viewed 15.1k times · Source

How can I add a percentage symbol % to the end of the last line in a text file?

I do not want the % to be on a new line, it must be at the end of the last line.

Thanks!

Answer

ghostdog74 picture ghostdog74 · Sep 7, 2010
sed '${s/$/%/}' file