i have data in this form
Kure|Hiroshima
Kure|Hiroshima
Kure|Hiroshima
NO MATCHING
Aachen|
Darmstadt
Mulheim
Aachen|
and i want to remove the last character only if it is a pipe (|).
desired output
Kure|Hiroshima
Kure|Hiroshima
Kure|Hiroshima
NO MATCHING
Aachen
Darmstadt
Mulheim
Aachen
Thanks in advance
You can use
sed
for this:It looks for
|
together with$
(which means "end of line") and deletes it.Note you can use
sed -i
in case you want to do an in-place edit.An
awk
version: