0
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!

anubhava
  • 761,203
  • 64
  • 569
  • 643

3 Answers3

2

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.

Community
  • 1
  • 1
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
0

Bourne doesn't do process substitution, i.e. >(...). Use bash instead.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

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
glenn jackman
  • 238,783
  • 38
  • 220
  • 352