I have the following script
#!/bin/bash
set i=0;
while read line
do
echo "$line";
$i < cat "my.log" | grep -w '$line' | wc -l;
echo "$i";
i=0;
done < "test.txt"
test.txt
has values like
abc
def
lmn
my log has values like
> INFO 2013-08-16 13:46:48,660 Index=abc insertTotal=11
> INFO 2013-08-16 13:46:48,660 Index=abcd insertTotal=11
> INFO 2013-08-16 13:46:48,660 Index=def insertTotal=11
> INFO 2013-08-16 13:46:48,660 Index=abcfe insertTotal=11
The goal is to pick each value from the test.txt
and to search for that pattern in the my.log
file.
The number of times the pattern is found is assigned to the variable i
.
I am going to check the value of i
and if it is 0
or the pattern was not found then I want that pattern to be stored in another file.
Currently, I am getting
./parser.sh: line 7: cat: No such file or directory
I have tried the cat command on the command line and it has worked fine but it is giving this error from within the script.