I have this set of lines in a file:
{info},
{info},
{info},
{info},
and I want the file like this without the last ",":
{info},
{info},
{info},
{info}
How can I do it in bash? Any idea?
You can use sed:
sed '$ s/.$//' your_file
$ is to tell sed to match only last lines is for "substitute", note the empty string between the two last /s.$ is a regex that matches the last character in the fileNote that you can use whatever separator you want instead of /, for example you can rewrite the expression:
sed '$ s-.$--' your_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