I have a log file, name out.log. I need to search a list of string (filelist.txt) from this log file.
I need each matching line from "out.log" for every file in filelist.txt. it can appear multiple times.
cat out.log | grep -i I466030.CXR910E >> search_result.txt
this works, it will search for I466030.CXR910E and output to search_result.txt
for i in `cat filelist.txt`; do grep -i "$i" out.log >> result.txt; done
for i in `cat filelist.txt`;
do
echo $i
cat out.log | grep -i $i >> result2.txt
grep $i out.log >> result3.txt
done
Above code the echo will output the search string but none of the grep not writing output to any result*.txt
What am I missing here ? Thanks for your advice.
In response to comments:
xxxxxm@cxxxrtrls01[DEV][rerun] $ grep -i -f filelist.txt out.log > result.txt
xxxxxm@cxxxrtrls01[DEV][rerun] $ ll
total 564
-rw-r----- 1 cnrlsadm cnrlsadm 4600 Aug 19 09:36 filelist.txt
-rw-r----- 1 cnrlsadm cnrlsadm 216 Aug 19 10:14 file.sh
-rw-r--r-- 1 cnrlsadm cnrlsadm 557403 Aug 19 10:10 out.log
-rw-r--r-- 1 cnrlsadm cnrlsadm 0 Aug 19 12:14 result.txt
-rw-r----- 1 cnrlsadm cnrlsadm 213 Aug 19 12:10 srch.sh
xxxxxm@cxxxrtrls01[DEV][rerun] $
size of result.txt is zero , it doesnt have anything.