wyldsj
asked on
simple sed question
Hi, I have a text file test.dat which is generated by:
echo "one\r\ntwo\nthree\r\nfour " > test.dat
in vi editor, it looks like this:
one^M
two
three^M
four
Now what I want is to replace all the occurance of "\r\n" by a space " ". Which means I want my output to be:
one two
three four
I tried the sed command like this:
sed 's/\r\n/ /g' test.dat > test2.dat
but it doesn't work at all. test2.dat is the same as test.dat.
May I know what is the correct way of doing this? It doesn't have to be sed, so long as it works I dont mind its perl or awk or whatever.
Thanks a lot in advance.
wyldsj
echo "one\r\ntwo\nthree\r\nfour
in vi editor, it looks like this:
one^M
two
three^M
four
Now what I want is to replace all the occurance of "\r\n" by a space " ". Which means I want my output to be:
one two
three four
I tried the sed command like this:
sed 's/\r\n/ /g' test.dat > test2.dat
but it doesn't work at all. test2.dat is the same as test.dat.
May I know what is the correct way of doing this? It doesn't have to be sed, so long as it works I dont mind its perl or awk or whatever.
Thanks a lot in advance.
wyldsj
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER