sed/awk/cut/grep.. looking for the best solution
Hi,
Im looking for a way to get variables out of a string.. There are a few forms that the string can be inputed by the user- thats the problem. i need to seperate the string into 3 vars.. ($first $sign $second) a few examples: "name=jack" "year>1980" "age<25" "name>abcd" "price=59.99" ok, you get the idea.. the first(left) part of the string will always be a word. The middle(sign) can only be: < , > , = . and the third(right) part can be a number or a word, as described at the example. if the third part is a word it will do a string compare. I need to execute an IF statement out of the string i get. so im trying to first store each part of the string so i can know whats going on before writing the statement. Thanks a lot for the helpers- any idea will B welcome! |
Using only variables and parameter substitution:
Code:
string="name=jack" |
thanks!
wow what a quick reply.. thx it looks great.. ill give it a try
|
Great
works 100% , problem solved!
Thanks 10x |
Hi,
Been playing around with this one and looks like it works. File contains Code:
test=exit1 Code:
cat test | awk -F'=|<|>' '{ print $2 , $1 }' Code:
exit1 test Kind regards, Eric |
All times are GMT -5. The time now is 08:21 AM. |