Results 1 to 4 of 4
Hi.
The last command in the bash code below gives output I did not expect.
Code:
daan@schmauck:~/tst$ ls
abc abc.sfv abx.sfv sfvsort
daan@schmauck:~/tst$ ls | tail -n1
sfvsort
daan@schmauck:~/tst$ cksfv ...
- 02-11-2008 #1
cksfv prints output, but it cannot be 'caught'
Hi.

The last command in the bash code below gives output I did not expect.
I expected there the out put to beCode:daan@schmauck:~/tst$ ls abc abc.sfv abx.sfv sfvsort daan@schmauck:~/tst$ ls | tail -n1 sfvsort daan@schmauck:~/tst$ cksfv -f abc.sfv --( Verifying: abc.sfv )-------------------------------------------------------- abc OK -------------------------------------------------------------------------------- Everything OK daan@schmauck:~/tst$ cksfv -f abc.sfv | tail -n1 --( Verifying: abc.sfv )-------------------------------------------------------- abc OK -------------------------------------------------------------------------------- Everything OK daan@schmauck:~/tst$
, just like the output of the second command is only one line. I've also tried saving the output of the last command to a variable:Code:Everything OK
The variable is empty! What is going on here?Code:daan@schmauck:~/tst$ result=$(cksfv -f abc.sfv | tail -n1) --( Verifying: abc.sfv )-------------------------------------------------------- abc OK -------------------------------------------------------------------------------- Everything OK daan@schmauck:~/tst$ echo $result daan@schmauck:~/tst$
- 02-11-2008 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
It seems that your command outputs his messages to stderr.
Redirects stderr to stdout and see what happens:
RegardsCode:2>&1 cksfv -f abc.sfv | tail -n1
- 02-11-2008 #3
Everything OK
Thanks.Code:daan@schmauck:~/tst$ 2>&1 cksfv -f abc.sfv | tail -n1 Everything OK

Can you explain what it does?
- 02-11-2008 #4Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
To understand how it works you can have a read of section 8.2.3 of this document:
http://tldp.org/LDP/Bash-Beginners-G...ers-Guide.html
Regards


Reply With Quote