I am trying to write a shell which will fetch a set of data from table and write it to a text file whose name is result.txt
. Now I will pick each line from this file and search it in a log file and check if it present or not. If it is not found in the log file I want to write it in a separate file say notfound.txt
. I am working on a AIX server and getting this below error for the grep
command. Can somebody please help me figure out what's wrong?
Here is my script,
while read -r LINE; do
grep -q "$LINE" log.log
if [ $? -eq 0 ]
then
echo "$LINE" >> /home/notfound.txt
fi
done < result.txt
which gives me following output,
grep: Not a recognized flag: - Usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...]
Usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...]
Usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...]
read
, the syntax isIFS= read -r line
. WithoutIFS=
, blanks are stripped from the beginning and end of the line.