Solved

simple sed question

Posted on 2000-03-12
2
232 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
Comment Utility
perl -pe 's/\r\n/ /' test.dat > test2.dat
0
 

Author Comment

by:wyldsj
Comment Utility
That's neat. Thx.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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…

763 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

11 Experts available now in Live!

Get 1:1 Help Now