cat /tmp/SYSLOG | tee >( egrep -i "session limit" > sess.txt) | egrep "dst_port=3389 " > dst.txt
Works n C-shell but not Bourne. I escaped the brackets and it no longer complains but it does not work. HELP!
cat /tmp/SYSLOG | tee >( egrep -i "session limit" > sess.txt) | egrep "dst_port=3389 " > dst.txt
Works n C-shell but not Bourne. I escaped the brackets and it no longer complains but it does not work. HELP!
That looks like Process substitution in bash
.
If you're looking for genuine Bourne shell (rather than bash
), you will have your work cut out simulating that. In fact, your best bet would be to obtain a program that explicitly runs other programs (pee
is one such; ISTR there being others — see Is it possible to distribute stdin over parallel processes? where GNU parallel
is mentioned).
If you can't do that either, then you'll have to revisit the code. The simplest fix looks like:
egrep -i "session limit" /tmp/SYSLOG > sess.txt &
egrep "dst_port=3389 " /tmp/SYSLOG > dst.txt &
wait
This runs the commands in parallel. The second &
is unnecessary but present for symmetry. In fact, this will work in any shell, so it is the portable solution. Unless the cat /tmp/SYSLOG
operation is actually a complex program, this works at least as neatly as the original code.
Bourne doesn't do process substitution, i.e. >(...)
. Use bash instead.
You can call out to awk in your bourne shell script:
awk '
tolower($0) ~ /session limit/ {print > "sess.txt"}
/dst_port=3389 / {print > "dst.txt"}
' /tmp/SYSLOG
If you happen to have GNU awk:
gawk -v IGNORECASE=1 '
/session limit/ {print > "sess.txt"}
/dst_port=3389 / {print > "dst.txt"}
' /tmp/SYSLOG