5
I'm trying to add a string at the end of all lines in a text file, but I have a mistake somewhere.
Example:
I've this in a text file:
begin--fr.a2dfp.net
begin--m.fr.a2dfp.net
begin--mfr.a2dfp.net
begin--ad.a8.net
begin--asy.a8ww.net
begin--abcstats.com
...
I run:
sed -i "s|\x0D$|--end|" file.txt
And I get:
begin--fr.a2dfp.net--end
begin--m.fr.a2dfp.net--end
begin--mfr.a2dfp.net--end
begin--ad.a8.net
begin--asy.a8ww.net--end
begin--abcstats.com
...
The string is added only in certain lines and not in others.
Any idea why?
Yes, it's a text file from Windows edited in Linux.
dos2unixreally solve problem and now, add--endat the end of all my lines. Thank You!!!! – rkifo – 2014-01-30T17:54:46.557@user294721 if this answer solves your problem, please remember to mrk it as accepted. – terdon – 2014-01-30T18:06:13.420
1you can remove the carriage returns in the same sed:
sed 's/\r\?$/--end/'– glenn jackman – 2014-01-30T18:17:08.523