Hi,
This post follows the one i posted a few days ago and which was magnificently answered by aigles
I would like to extend my request script .for that i would like it to search character strings in addition to integers.
The variables (for example) have these values:
ID=1
DESIGNATION=2
PRICE=3
STOCK=4
and correspond to the name and field number of the file from which are made the requests
i would like to transform condition part the command line request
"WHERE Designation==Sav" to:
$2 ~ /Sav/ ,maybe with a sed for further use as an if condition in an awk
Here's my actual sed:
CONDITION=$(echo $2 | \
tr '[a-z]' '[A-Z]' | \
sed -e 's/^.*WHERE //' \
-e 's/[ \t]AND[ \t]/ \&\& /g' \
-e 's/[ \t]OR[ \t]/ || /g' \
-e 's/\([A-Z_]\+\)/\\\$\$&/g' \
-e 's/ //g')
eval CONDITION=\"$CONDITION\"
For example with the condition request:
WHERE Designation==Sav AND Stock>10, i would like it to become:
$2 ~ /Sav/ && $3>10
I would only like to transform it what's after == is a character string:
i don't want it to mess with Stock==10 which becomes $3==10
Any Help would be hugely appreciated