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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -