![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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
|
|||
|
|||
|
echo variable1`expr match 'column_id.columnname=="value"' '.*\(==.*\)'`
|
|
#4
|
|||
|
|||
|
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
|
|||
|
|||
|
The problem would depend a great deal on what the output of that command is.
|
|
#6
|
|||
|
|||
|
the output should be
`echo $line_by_line | awk -F "|" '{print $1}'`>=5 thanks and regards mahabunta |
|
#7
|
|||
|
|||
|
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
`echo $line_by_line | awk -F "|" '{print $1}'` >= 5 |
|||
| Google The UNIX and Linux Forums |