Solved

shell problem.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using Grep to Find a file 8 107
NTP Server in VMware 5 387
Invalid password trying to cannect to Unix server 2 96
Shell Script- gzip 5 47
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

749 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