Piping and redirection: CON:

May 20, 2008
Syracuse, NY, USA
An analogy (?):

Think of the tap on your kitchen sink. "Open tap" produces water and the normal destination for that water is "down the drain". If you want to "filter" the water before it goes to the normal destination, you "pipe" it to the filter. Technically, the output of "open tap" becomes the input of "filter" and the output of "filter" goes to the normal destination (down the drain). That would be

"open tap" | "filter"

Maybe you want to filter it in many ways:

"open tap" | "filter1" | "filter2"

If, you'd rather have the water go into a pitcher (than down the drain), you "redirect" the output.

"open tap" | "filter" > "pitcher"

At this point it's over; the water has reached it's destination. If you want do to more (filter further, or change the location of the water) you must start over with an action that produces water, perhaps

"pour water out of pitcher" | "filter3" > "glass"

A bit more technically, the "stdin" and "stdout" streams (programming terms) start with a process that produces data (stdout) which normally is written to the console. You can make things happen to that data (before it reaches its destination) with pipes. Pipes send the stdout of one process to the stdin of another process (not changing the ultimate destination). If you want to change the destination, redirect. Redirection is to a device (file, display, clipboard, ..., not to a process) and after redirection, the input/output chain is finished..

So, your second example is odd in two ways.

1. "DIR > CON:" is, at best, redundant. That's where DIR's output goes by default.

2. After "DIR > CON:" the output has been disposed of. There is no output to send to VIEW.

I may be wrong, but I don't think it makes sense to follow a redirection with a pipe.

I hope all that makes some sense.
Aug 3, 2016

Although I knew most of it, I couldn't "pipe" the info together :-)
The thing that did wonder me was that DIR sends it's output to con and so would DIR>CON:
I didn't see the difference, but now I'm enlightened! :-)
May 20, 2008
Syracuse, NY, USA
P.S., Read about the TEE command for doing two things with output. A little example:
v:\> echo foo^r^nbar | tee clip: | findstr bar

v:\> type clip:
Aug 3, 2016
An analogy (?):
I may be wrong, but I don't think it makes sense to follow a redirection with a pipe.

I used it for this, for example:
ATTRIB /D /S c:\* 1>nul |& ssed.exe -e /^TCC.*denied.$/{;N;d} -e /^TCC:.*files.$/d -e s/\\\*//

Redirect standard output of ATTRIB to nul: and whatever remains (i.e standard error ) goes in a pipe (std output + std error) to be processed by SED
Similar threads
Thread starter Title Forum Replies Date
vefatica Redirection vs. piping? Support 4
vefatica Piping turns on the cursor Support 0
vefatica Trouble piping Support 3
vefatica Piping to WSL? Support 4
H Behavior change re piping a string to a Java program Support 1
vefatica Piping Cscript.exe to HEAD? Support 9
vefatica Piping the output of a DO loop. Support 4
Peter Murschall TPIPE generate unicode on Piping or redirecting Support 3
vefatica Chaining and piping? Support 2
J Piping ANSI control sequences through 'type' Support 4
rps How to? Piping to View /gb Support 1
vefatica Piping to DO x in @con: Support 10
vefatica Fixed Piping to HEAD adds newlines Support 1
nikbackm Piping to new TCC instance crashes it Support 1
S Ctrl-C handling while piping Support 0
vefatica Redirection and memory leak? Support 3
A WAD Output redirection to IF block fails with "unbalanced brackets" Support 7
N multiple command alias and redirection Support 0
nikbackm Switch Case and here-document redirection Support 2
J WAD Output redirection in tcexit looses data Support 31
J Vers. 18 Here doc redirection broken? Support 4
I "IF" command in a variable does not expand redirection variable name Support 0
P Fixed TCC 17 describe redirection Support 3
vefatica Speeding up redirection to NUL? Support 32
fpefpe WOW64 Redirection Support 8
D Redirection to clip - env dependency? Support 3
W redirection with pipe don't work Support 10
A Dual redirection Support 3
krischik I/O redirection with start command. Support 6
L redirection to/by perl acts bizarrely Support 9
Charles Dye Strange output, here-doc redirection, TYPE, //UnicodeOutput=Yes Support 6
Daniel Wee Rexx output redirection seems to be broken Support 4
H "Here-String" redirection not working Support 6
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
vefatica ON BREAK (con't) Support 1
S @CON: does not work with sendmail for pipe Support 2
S CON: not processed correctly in @FILEREAD and @FILEARRAY Support 1

Similar threads