Solved

shell problem.

Posted on 2001-09-11
3
220 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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.

785 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