Solved

simple sed question

Posted on 2000-03-12
2
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

749 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