LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2007, 11:52 AM   #1
howarddevore
Member
 
Registered: Apr 2005
Distribution: not sure yet
Posts: 117

Rep: Reputation: 15
newb sed question


hello
I am trying to learn a bit about sed, and it is not behaving as I expected.
I have two files in a dir, old.txt and new.txt.
I cd to that dir, and have new.txt open in my text editor.

I wrote some junk text, with multiple instances of the word 'seems' and put it in both files.

The I ran sed:
sed s/seems/xxxx/ <old.txt>new.txt

It works - but only on the first instance of 'seems'.
I had been expecting it to replace all instances of it.

Can anyone give me a pointer please?

Thanks in advance.
Howard
 
Old 07-06-2007, 12:07 PM   #2
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Quote:
Originally Posted by howarddevore
hello
I am trying to learn a bit about sed, and it is not behaving as I expected.
I have two files in a dir, old.txt and new.txt.
I cd to that dir, and have new.txt open in my text editor.

I wrote some junk text, with multiple instances of the word 'seems' and put it in both files.

The I ran sed:
sed s/seems/xxxx/ <old.txt>new.txt

It works - but only on the first instance of 'seems'.
I had been expecting it to replace all instances of it.

Can anyone give me a pointer please?

Thanks in advance.
Howard
sed s/seems/xxxx/g <old.txt>new.txt
 
Old 07-06-2007, 12:26 PM   #3
howarddevore
Member
 
Registered: Apr 2005
Distribution: not sure yet
Posts: 117

Original Poster
Rep: Reputation: 15
newb sed question

hello
I am trying to learn a bit about sed, and it is not behaving as I expected.
I have two files in a dir, old.txt and new.txt.
I cd to that dir, and have new.txt open in my text editor.

I wrote some junk text, with multiple instances of the word 'seems' and put it in both files.

The I ran sed:
sed s/seems/xxxx/ <old.txt>new.txt

It works - but only on the first instance of 'seems'.
I had been expecting it to replace all instances of it.

Can anyone give me a pointer please?

Thanks in advance.
Howard
 
Old 07-06-2007, 12:48 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Try
Code:
sed 's/seems/xxxx/g' old.txt > new.txt
Dave
 
Old 07-06-2007, 01:49 PM   #5
howarddevore
Member
 
Registered: Apr 2005
Distribution: not sure yet
Posts: 117

Original Poster
Rep: Reputation: 15
aha!
Thanks Dave.
 
Old 07-06-2007, 02:50 PM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
g = global
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
sed question from Ch 6.12 na5m Linux From Scratch 1 02-02-2005 03:36 PM
sed question virendratp Programming 3 09-10-2004 03:21 AM
sed question zoomzoom Linux - Software 2 10-20-2003 04:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:05 AM.

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
Open Source Consulting | Domain Registration