Solved

simple sed question

Posted on 2000-03-12
2
239 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:wyldsj
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 2611092
perl -pe 's/\r\n/ /' test.dat > test2.dat
0
 

Author Comment

by:wyldsj
ID: 2611368
That's neat. Thx.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question