?
Solved

shell problem.

Posted on 2001-09-11
3
Medium Priority
?
235 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
[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
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 100 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

Industry Leaders: 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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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
Course of the Month12 days, 20 hours left to enroll

777 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