Solved

simple sed question

Posted on 2000-03-12
2
234 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to improve IO of Solaris machine 15 84
g++ pthread_init failure on AIX 10 71
How to find files recursively in ftp server quickly? 7 102
mobaxterm not able to change directory 28 111
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now