Solved

Regular Expression (sed editor)

Posted on 2002-07-14
2
325 Views
Last Modified: 2010-05-18
Hello !

I have following file, called for example "a.txt"

f_a
m_b

Now I want to replace each first character at a line followed by "_", by the same character followed by "@",
in other words I wish to receive following file.

f@a
m@b

It's important for me to execute the upper task using sed editor, and I do it in the following way:

>> sed s/"^(.)_"/"\0@"/ a.txt > b.txt

But for any reason this command doesn't work.

Can you please explain what is a problem.

Txs,
Alex

0
Comment
Question by:alexgor
[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 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 7152593
sed -e 's/^\(.\)_/\1@/' a.txt

problems are:
  1. usage of quotes
  2. number of matched patter is \1 not \0
0
 

Author Comment

by:alexgor
ID: 7152608
Thank you very much.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
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…

688 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