Removing Last Character from a File using 'sed' command

sed and awk are a programming language in themselves as the masters say. Truly, mastering half of the Unix scripting consists of mastering sed and awk commands.


Supposing you have a file myfile and you want to remove the last character from the file. The following command does this and saved the clean file without the junk characters in cleanfile

sed '$s/,$//' myfile > cleanfile