Reputation: 619
I have a file in Unix that has a '\' character at the end of every line. I would like to remove it from every line. There are over 1000 lines.
I have seen some examples, but didn't quite work. I am new to Unix and hoping I would get my answer here.
Thanks,
Ab
Upvotes: 0
Views: 479
Reputation: 33370
A Perl
one-liner.
perl -i~ -pe 's/\\$//' file
This will create a backup of the original with a ~
extension and replace every \
at the end of each line.
Upvotes: 0
Reputation: 433
This eliminates the last character of e sed 's/.$//' original_file > new_file
Upvotes: 0
Reputation: 185219
Try doing this :
sed -i.~ 's@\\$@@g' file.txt
EXPLANATIONS
-i
do the substitution for real in the file.~
makes backup files with this suffixs@@@
is the skeleton syntax for substitutions (I have arbitrary chosen @
as delimiter)$
mean end of lineUpvotes: 1