Visit Our UNIX and Linux User Community


HP Unix Tee command.


 
Thread Tools Search this Thread
Operating Systems HP-UX HP Unix Tee command.
# 1  
Old 09-21-2009
HP Unix Tee command.

work.txt
Code:
M|324324|32424|3431
N|324324|32426|3432
N|324324|32424|3434
M|324324|32424|3435

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

which does not work on HP? Please adivse us.
Error:
Code:
cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )
ksh: syntax error: `(' unexpected


Last edited by vgersh99; 09-21-2009 at 11:56 AM.. Reason: code tags, PLEASE!
# 2  
Old 09-21-2009
Code:
awk ' /^M/ {print $0 > "m.txt"}
       /^N/  {print $0 > "n.txt" } ' inputfile

# 3  
Old 09-21-2009
Thanks Jim. My code is below which does not work:

Code:
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.


Last edited by vgersh99; 09-21-2009 at 11:57 AM.. Reason: code tags, PLEASE!
# 4  
Old 09-21-2009
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 [code] and [/code] 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
# 5  
Old 09-21-2009
Tee command using pipe

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.
# 6  
Old 09-22-2009
Quote:
AIX command:
Code:

cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )
Code:
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

# 7  
Old 10-27-2009
Quote:
Here reading twice from pipe1 -- instead of that can we read only once using tee command.
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.

Previous Thread | Next Thread
Test Your Knowledge in Computers #214
Difficulty: Easy
Cisco Internetwork Operating System (IOS) is a family of network operating systems used on many Cisco Systems routers and current Cisco network switches originally designed by Sun Microsystems.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Using tee command with ablity to provide input for prompts

OS version: RHEL 7.4 Shell : bash I would like to capture command outputs using tee like # yum upgrade | tee yumupgradeLog But, if I use tee command, I cannot respond to prompts like Is this ok : during command execution as shown below. Is there a way I could use tee and still be able to... (4 Replies)
Discussion started by: kraljic
4 Replies

2. Shell Programming and Scripting

Help required with Stderr and tee command

Hello All, I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file. Can someone please help me with this? Thanks in advance (2 Replies)
Discussion started by: vikas_trl
2 Replies

3. Shell Programming and Scripting

Question about tee command

I have the following script as shown below where I cat a file and then also tee the output to a file as I have to email the execution of the process to users at the end of the script: cat incoming.dat | tee -a execution.log if then echo "Issue with incoming.dat file, file not... (5 Replies)
Discussion started by: calredd
5 Replies

4. UNIX for Dummies Questions & Answers

Problems with tee command.

for i in /tmp/*filex*; do echo $i |sed 's/\/tmp/infofiles\/infosize\/db\/files\///g';done 2>&1 |tee>output | The script works fine, but I cannot get the output to go to the screen and output at same time. I've tried tee -a tee and a number of commands but the only way I can get it working is... (3 Replies)
Discussion started by: newbie2010
3 Replies

5. Shell Programming and Scripting

Help with tee command

In the current directory , I have seven files . But when I use the following command , it lists eight files ( 7 files + file_list.xtx) ls -1 | tee file_list.xtx | while read line; do echo $line ; done Does the tee command create the file_list.xtx file first and then executes the ls -1... (1 Reply)
Discussion started by: kumarjt
1 Replies

6. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

7. Shell Programming and Scripting

tee + more command

script1: #!/bin/ksh more test.txt script2: calling the script1 #!/bin/ksh /tmp/script1.sh 2>&1 | tee tee.log where test.txt contains ~1200 lines. When I execute the script2 the more command does not print pagewise it goes to the end of the line, when I remove the tee command it... (4 Replies)
Discussion started by: prasad111
4 Replies

8. UNIX for Dummies Questions & Answers

tee command within variable

Hello If anybody knows something about the following please help me. I am using HP unix. In a script called test.txt i have the following command echo ok | tee test1.txt It works fine.It prints ok on the screen and creates the file test1.txt and puts in the file the "ok". In the same... (2 Replies)
Discussion started by: kostasch
2 Replies

9. UNIX and Linux Applications

Tee with pipe command.

cat work.txt M|324324|32424|3431 M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 cat work.txt | tee $( grep '^M' > m.txt ) | $( grep '^N' > n.txt ) cehpny00:/home01/sr38632 $ cat m.txt M|324324|32424|3431 M|324324|32424|3431 M|324324|32424|3435 ... (2 Replies)
Discussion started by: rsampathy
2 Replies

10. Shell Programming and Scripting

How Unix tee to send pipeline output to 2 pipes ?

Hi, I would like to process, filter the same ASCII asynchronous live data stream in more than one pipe pipeline. So the one pipeline should filter out some records using grep key word and more than one pipes pipelines each should grep for another key words, each set seperately for each... (5 Replies)
Discussion started by: jack2
5 Replies

Featured Tech Videos