Solved

shell problem.

Posted on 2001-09-11
3
214 Views
Last Modified: 2013-12-27
my file is having an entry like this


hello how are u msnr


using shell script i want to replace msnr with user2

how can i do this.?
same way how can i modify multiple lines.

thans
0
Comment
Question by:msnr
  • 2
3 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6474322
That's not too difficult. Use 'cat my-file | sed -e "s/msnr/usr2" >my-file' to change the files in place or 'sed -e "s/msnr/usr2/" <in-file >out-file" to retain the original files.
0
 
LVL 1

Author Comment

by:msnr
ID: 6474557
i want to append to the line as

hello how are u msnr:usr2

can i.?

msnr
0
 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
ID: 6475086
Sure the sed command I used above silmply replaces 'mnsr' with 'user2. If you want to replace it with 'msnr:usr2' use 'sed -e "s/mnsr/mnsr:usr2/ <in-file >out-file'.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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

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

22 Experts available now in Live!

Get 1:1 Help Now