have to write a script; on the command line, it's (as one-liner):
time while read line; do echo -n "$line "; grep -P -m 1 "\t[A-Z]$line" logfile |wc -l; done < <(tail db.txt)
The time is only for debugging as is the tail and the script works
If I put it in a file
while read line;
echo -n "$line ";
grep -P -m 1 "\t[A-Z]$line" logfile |wc -l;
done < <(tail db.txt)
and execute with sh verify.sh, it complains about the last line
Can someone explain to me why ?
wim@btd-techweb01:~/log$ sh verify.sh
verify.sh: line 5: syntax error near unexpected token `<'
verify.sh: line 5: `done < <(tail db.txt)'
I assume that the input redirection has to be outside the file, but it does not explain the why.
If I add '#!/bin/bash' at the beginning of verify.sh and make it executable, it works (again) as expected.
I will probably post some more questions as it needs some serious optimisation and a slight modification.