LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-29-2003, 09:36 AM   #1
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Rep: Reputation: 30
Help with sed


I need some help. I am working with a bunch of little scripts where I need to change directories. I tried to use sed:

sed -n s/user1/user2/p script

The problem is that that it will only change some of the instances in the file. I'm sure that it is bacause ther are no spaces; but thats whats strange it picks some of the embedded item out but not others.

Guess what I am asking is there a way to change:

/mkdir/homes/usr1 to /mkdir/homes/usr2 in a script?

Thanks a bunch
 
Old 08-29-2003, 10:59 AM   #2
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
try sed 's/usr1/usr2/g' filename
The g option specifies global so if you have 2 instances in the same line like:
/home/foo/usr1 /home/bar/usr1
then it will change them to:
/home/foo/usr2 /home/bar/usr2

Hope that Helps
 
Old 08-29-2003, 11:52 AM   #3
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Original Poster
Rep: Reputation: 30
Man!! that works great. That is not in my man pages that I saw. Thanks a bunch.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-04-2005 12:00 AM
Sed q? ky-lab_rat Linux - Software 5 10-26-2004 08:59 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM
help with sed DavidPhillips Programming 3 08-11-2003 05:46 PM
sed.... BongFish Linux - Software 4 08-07-2003 10:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration