Hello,
I have following problem.
I have the result of a database request. I preparated the result via sed, etc. as a string in a file.
The string in the file is:
($3==1 || $3==2 || $3==3 || $3==4)
Now I want to use the String as a command in an if-statement.
So I assigned the string to a variable:
ABC=$(<dir/file)
So far - so good:
echo $ABC gives me as a result: ($3==1 || $3==2 || $3==3 || $3==4)
But with nawk it doesn't work.
For clarification: If I would use the string directly (and so static), my awk would be written like here:
#If we find the values 1,2,3 or 4 in column 3, so change the value in column 4 into 10 in the relevant rows.
nawk '{FS=";";OFS=";"; if ($3==1 || $3==2 || $3==3|| $3==4) {$5=10}; print $0}' dir/file1.txt > dir/file2.txt
But dynamically it doesn't work. My idea was following:
nawk '{FS=";";OFS=";"; if ($ABC) {$5=10}; print $0}' dir/file1.txt > dir/file2.txt
I tested everything, with echo $ABC, cat, different brackets... but without success.
Is anybody able to help me and explain to me what I have to change, please?
Thanks a lot and Kind Regards
Dr_Aleman