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!
Using tee Command: The tee command copies the text from standard input and writes it to the standard output file. The tee provides -a option to append the text to the file.
There are two standard ways of appending lines to the end of a file: the “>>” redirection operator and the tee command. Both are used interchangeably, but tee's syntax is more verbose and allows for extended operations.
You can use the cat command to append data or text to a file. The cat command can also append binary data. The main purpose of the cat command is to display data on screen (stdout) or concatenate files under Linux or Unix like operating systems.
sed '${s/$/%/}' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With