Solved

Regular Expression (sed editor)

Posted on 2002-07-14
2
318 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 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…
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…
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.

760 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

18 Experts available now in Live!

Get 1:1 Help Now