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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 01:12 PM
Content of Content of a variable! jaduks Shell Programming and Scripting 2 08-27-2007 12:40 AM
Using the content of a file in the name of another anriot Shell Programming and Scripting 2 09-18-2006 07:56 PM
Mass Change content in all files terala Shell Programming and Scripting 1 11-20-2005 01:30 AM
Content-Type primal UNIX for Dummies Questions & Answers 1 12-21-2001 12:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-19-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
how to change the content thru sed.....

Hi Everybody,

Another headache form myside,

i have a file name noname.txt having content as
CS007=NEW

and i have to write a scipt which will take the parameters as update,delete... with the 1st field of noname.txt (i.e. here CS007)
whose objective is to change the 2nd field of noname.txt as update or delete as per the input.

how can i achieve this for the following line.......
sed ' /CS007/ c\CS007=UPDATE' noname.txt using the variables...

like

sed ' /$1/ c\$1=$2' noname.txt

any other suggestions are also welcome....

  #2 (permalink)  
Old 09-19-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
sed " /$1/ c\$1=$2" noname.txt

should do...
  #3 (permalink)  
Old 09-19-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
An alternative in Perl:
Code:
perl -pi -e "s/(CS007=)NEW/\1UPDATE/" noname.txt
but probably this doesn't fit your requirement
  #4 (permalink)  
Old 09-22-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
Thanx a lot....

the following method is also working,

'/'"$1"'/ c\'"$1"="$2"
Closed Thread

Bookmarks

Tags
perl, sed

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 12:34 AM.


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