The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do I search for 2 strings (AND operator) ? Kartheg UNIX for Dummies Questions & Answers 14 09-11-2009 04:44 PM
how to search with 2 strings. syamkp Shell Programming and Scripting 2 03-10-2008 04:50 AM
search a logfile for strings amitrajvarma UNIX for Dummies Questions & Answers 0 11-25-2007 10:09 AM
Search between strings with an OR pbsrinivas Shell Programming and Scripting 3 07-12-2007 04:46 AM
awk search for Quoted strings (') kprattip Shell Programming and Scripting 13 07-10-2007 03:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-25-2002
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
Search for strings

I am trying to replace the word ACTIVE with 2002 in a file and I am getting the following error. Does anyone know what this means?

$ sed "s/ACTIVE/2002" mydata.txt > yourdata.txt
sed: 0602-404 Function s/ACTIVE/2002 cannot be parsed.
  #2 (permalink)  
Old 04-25-2002
apalex apalex is offline
Registered User
  
 

Join Date: May 2001
Location: NY
Posts: 39
try:

sed '/ACTIVE/s//2002/' mydata.txt > yourdata.txt
  #3 (permalink)  
Old 04-26-2002
inpavan inpavan is offline
Registered User
  
 

Join Date: Sep 2001
Posts: 36
Try

sed "s/ACTIVE/2002/g" your_file > new_file
  #4 (permalink)  
Old 04-26-2002
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
Thanks

They both work, but what is the difference between what I had:

sed "s/ACTIVE/2002" mydata.txt > yourdata.txt


and

sed "s/ACTIVE/2002/g" your_file > new_file

What does the g do?
  #5 (permalink)  
Old 04-26-2002
apalex apalex is offline
Registered User
  
 

Join Date: May 2001
Location: NY
Posts: 39
you are missing a slash (/) after 2002 in your original command.

sed "s/ACTIVE/2002/" myfile.txt > yourfile.txt

this replaces the first occurrence of text ACTIVE with 2002 in each line.

g means it will replace all occurrences of the text ACTIVE with 2002.
  #6 (permalink)  
Old 04-26-2002
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
thanks.

that helps.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0