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
find and replace javeed7 Shell Programming and Scripting 1 04-02-2008 09:00 AM
find and replace rakshit Shell Programming and Scripting 4 01-24-2008 03:52 AM
find and replace valhutch UNIX for Dummies Questions & Answers 4 07-29-2006 05:20 PM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 05:41 PM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 04:17 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 09-20-2006
mahabunta mahabunta is offline
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
  #2 (permalink)  
Old 09-20-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
Code:
# echo "column_id.columnname==\"value\"" | sed 's/column_id\.columnname/variable1/g'
variable1=="value"
# sed -i 's/column_id\.columnname/variable1/g' filename
#
  #3 (permalink)  
Old 09-20-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
echo variable1`expr match 'column_id.columnname=="value"' '.*\(==.*\)'`
  #4 (permalink)  
Old 09-20-2006
mahabunta mahabunta is offline
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
  #5 (permalink)  
Old 09-20-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
The problem would depend a great deal on what the output of that command is.
  #6 (permalink)  
Old 09-20-2006
mahabunta mahabunta is offline
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
  #7 (permalink)  
Old 09-21-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,507
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
Sponsored Links
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 09:37 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