[SOLVED] AWK - Word search
by Pinguino99 from LinuxQuestions.org on (#54KP8)
hi, i have a little problem in the code, if don't find the word it doesn't change to second condition
What is wrong?
File
Code:1: zzz|zzz|bbb|[X]|999|222
2: xxx|xxx|bbb|[Y]|999|222Code:FILE=~/path/file
read -p "word: " STRING
if
awk -F '|' '{if($4 && NR==1) print $4~/^\['$STRING']/}' $FILE ; then
echo "found"
else
echo "not found"
fi


What is wrong?
File
Code:1: zzz|zzz|bbb|[X]|999|222
2: xxx|xxx|bbb|[Y]|999|222Code:FILE=~/path/file
read -p "word: " STRING
if
awk -F '|' '{if($4 && NR==1) print $4~/^\['$STRING']/}' $FILE ; then
echo "found"
else
echo "not found"
fi