?
Solved

Regular Expression (sed editor)

Posted on 2002-07-14
2
Medium Priority
?
326 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 400 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

764 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