The UNIX and Linux Forums  

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
find and replace javeed7 Shell Programming and Scripting 1 04-02-2008 06:00 AM
find and replace rakshit Shell Programming and Scripting 4 01-24-2008 12:52 AM
find and replace valhutch UNIX for Dummies Questions & Answers 4 07-29-2006 02:20 PM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 02:41 PM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 01:17 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-20-2006
Registered User
 

Join Date: Aug 2006
Posts: 45
find and replace

I have statement like this

column_id.columnname=="value"

in unix i want to modify above statement to

variable1=="value"

that means i have to replace the string before "==" by string "variable1"
second catch is, in statement instead of "==" you can have any arithmatic comarision operator like !=, >, < etc...

can have replace string befor first " and replace by variable1==

can anyone suggest command to do this...

regards
mahabunta
Reply With Quote
Forum Sponsor
  #2  
Old 09-20-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 989
Code:
# echo "column_id.columnname==\"value\"" | sed 's/column_id\.columnname/variable1/g'
variable1=="value"
# sed -i 's/column_id\.columnname/variable1/g' filename
#
Reply With Quote
  #3  
Old 09-20-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
echo variable1`expr match 'column_id.columnname=="value"' '.*\(==.*\)'`
Reply With Quote
  #4  
Old 09-20-2006
Registered User
 

Join Date: Aug 2006
Posts: 45
hi i have

statement 15_REC_D>=5

here 15_REC_D needs to be replaced by `echo $line_by_line | awk -F "|" '{print $1}'`

so i have used command
echo -e "15_REC_D>=5" | sed 's/"15_REC_D"/"\`echo $line_by_line | awk -F "|" '{print $1}'\`"/g'

but it is giving me error as
sed: -e expression #1, char 58: Unterminated `s' command

Any inputs on above error

thanks and regards
mahabunta
Reply With Quote
  #5  
Old 09-20-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 989
The problem would depend a great deal on what the output of that command is.
Reply With Quote
  #6  
Old 09-20-2006
Registered User
 

Join Date: Aug 2006
Posts: 45
the output should be

`echo $line_by_line | awk -F "|" '{print $1}'`>=5

thanks and regards
mahabunta
Reply With Quote
  #7  
Old 09-21-2006
Registered User
 

Join Date: Sep 2006
Posts: 1,580
here's a simple python alternative:
Code:
s = "15_REC_D>=5"
replacestring = """`echo $line_by_line | awk -F "|" '{print $1}'`"""
tobereplaced , num = s.split(">=")
print replacestring,">=",num
output:
`echo $line_by_line | awk -F "|" '{print $1}'` >= 5
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0