HP Unix Tee command.

work.txt

M|324324|32424|3431
N|324324|32426|3432
N|324324|32424|3434
M|324324|32424|3435

AIX command:

cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )

which does not work on HP? Please adivse us.
Error:

cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )
ksh: syntax error: `(' unexpected
awk ' /^M/ {print $0 > "m.txt"}
       /^N/  {print $0 > "n.txt" } ' inputfile

Thanks Jim. My code is below which does not work:

mkfifo $StdMarPbPipe1 && mkfifo $StdMarPbPipe2

ce_bcp.ksh -i out -d itg_credit -t samtmpv1 -f $StdMarPbPipe1 -F "|" -H "|" &

tee $StdMarPbPipe2 < ( $StdMarPbPipe1 | grep "^N" | cut -d '|' -f 2-4 | sort -u > TestMarPbN.txt) &

grep "^M" $StdMarPbPipe1 | cut -d '|' -f 2-4 | sort -u > TestMarPbM.txt

Objective is:

step1: Internal Bcp to -> pipe $StdMarPbPipe1

Then reading pipe1--> grep '^N' | cut | sort > TestMarPbN.txt
Then reading pipe2--> grep '^M' | cut | sort > TestMarPbM.txt

Like to use Tee command to avoid reading twice from pipe1.

[LEFT][/LEFT]

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

work text.txt:
M|324324|32424|3431
N|324324|32426|3432
N|324324|32424|3434
M|324324|32424|3435
mkfifo $pipe1 $pipe2
tee $Pipe2 < ( $pipe1 | grep "^N" | cut -d '|' -f 2-4 | sort -u > TestMarPbN.txt) &
grep "^M" Pipe1 | cut -d '|' -f 2-4 | sort -u > TestMarPbM.txt

Here reading twice from pipe1 -- instead of that can we read only once using tee command.

an12:/home/vbe $ cat work.txt
M|324324|32424|3431
N|324324|32426|3432
N|324324|32424|3434
M|324324|32424|3435
an12:/home/vbe $ cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )
ksh: 0403-057 Syntax error: `(' is not expected.
an12:/home/vbe $ oslevel
6.1.0.0

You're attempting process substitution, and that is only available on systems that support the /dev/fd/N special files for named access to previously opened file descriptors.

My hp-ux version (11.11) does not support this. I'm not sure if the newer versions are supposed to support it or not.

The construct

>(cmd)

is a ksh/bash feature.

sed -e '/^M/w m.dat' -e '/^N/w n.dat' -ed work.txt