I have a scenario where I want to filter log files. To do this I am wanting to follow the last 10 lines or so of a log file and as new lines are read in, pipe them through an awk program and then redirect the output to a listening port on a remote host via netcat.
Currently my script has the following line in it:
echo "\`awk -f rules.awk <(tail -F $@)\`" | nc -u 127.0.0.1 5004
$@ is the list of arguments supplied in the initial call and rules.awk simply contains some desired patterns to match on.
Calling the script with
./script logfile.log appears to do nothing and the script hangs. I speculate that the pipe actually requires a process to terminate before its final output is actually piped to the new command.
So I tried a different approach running the following in my terminal:
nc -u 127.0.0.1 5004 <(awk -f rules.awk <(tail -F logfile.log))
This resulted in the following error:
Invalid port specification: /dev/fd/63
It appears that the redirect has actually passed the logical device of the stream rather than its 'value' but I'm just guessing again.
Could someone with a bit more BASH nous point me in the right direction with this?