linux - How to remove the last character from all lines but only if it is a certain character -
i have data in form
kure|hiroshima kure|hiroshima kure|hiroshima no matching aachen| darmstadt mulheim aachen| and want remove last character if pipe (|).
desired output
kure|hiroshima kure|hiroshima kure|hiroshima no matching aachen darmstadt mulheim aachen thanks in advance
you can use sed this:
$ sed 's/|$//' file kure|hiroshima kure|hiroshima kure|hiroshima no matching aachen darmstadt mulheim aachen it looks | $ (which means "end of line") , deletes it.
note can use sed -i in case want in-place edit.
Comments
Post a Comment