help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] pipe character at end of command ?


From: Ulf Andersson A
Subject: [Help-bash] pipe character at end of command ?
Date: Wed, 23 Nov 2016 15:46:17 +0000

Hello,

I am at my wits end. I have searched the bash manual and man page as well as 
numerous wikis and tutorials. All to no avail. I am trying this out on a Red 
Hat Linux engine. From  uname -a I get this

       Linux themachine 2.6.32-642.6.1.el6.x86_64 #1 SMP Thu Aug 25 12:42:19 
EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

Here is my little example:
--8><--------------------------------------------
#!/bin/sh
# Ape
# Banana
# Ladder
# A random comment

spunk()
{
   sed '/Ape/d'    |
   sed '/Banana/d' |
   sed '/Ladder/d'
}

cat $0 | spunk
--8><--------------------------------------------
I have figured out what the three sed commands do each by themselves, but I 
have still fo figure out what the pipe characters actually do here. And no, I 
did not forget to put any continuation characters at the end of the lines.

The above example produces this output:
--8><--------------------------------------------
#!/bin/sh
# A random comment

spunk()
{
}

cat $0 | spunk
--8><--------------------------------------------

Now if I remove the pipe characters from the script above, I get this output:
--8><--------------------------------------------
#!/bin/sh
# Banana
# Ladder
# A random comment

spunk()
{
    sed '/Banana/d'
    sed '/Ladder/d'
}

cat $0 | spunk# A random comment
--8><--------------------------------------------

Clearly there is some hand waving with the pipe going on, but as I said above, 
I have not found any kind of documentation of this behaviour. At least not any 
that I could understand. I might be blind, or something... :)

Could anyone explain this to me, please?

Best regards,

/Ulf Andersson A



reply via email to

[Prev in Thread] Current Thread [Next in Thread]