Questions tagged [pipe]

A pipe is an interprocess connection between file descriptors of two processes. A pipe is created with the POSIX pipe() function (from ). Shells create pipes between processes if the "|" symbol is used: "cmd1 | cmd2" directs the output of cmd1 to the input of cmd2. On Windows use CreatePipe(). This mechanism redirects standard input, standard output, and standard error into the calling process in .NET and Java.

Every program that runs on the command line has three data streams connected to it: STDIN(0) - standard input, STDOUT (1) - standard output - data printed by the program, STDERR(2) - standard error.

There are ways to connect streams between programs and files called piping and redirections.

Piping is a mechanism for sending data from one program to another using the "|" operator. The operator feeds the output from the program on the left as input to the program on the right.

Example

$ cat two_columns
column1:cloth
column2:strawberries
column3:fish
column4:chocolate
column5:punch cards
$ cat two_columns | awk -F: '{print $1}'
column1
column2
column3
column4
column5 
$ cat two_columns | awk -F: '{print "HAS: " $2}'
HAS: cloth
HAS: strawberries
HAS: fish
HAS: chocolate
HAS: punch cards 

Useful Links

9809 questions
22
votes
7 answers

Angular 2+ - check if Pipe returns an empty subset of original list

I have a list of strings that I want to iterate through, but I want to be able to filter them using a search term. Like this:
{{ item }}
My question is: how can I check if the pipe returns an…
22
votes
5 answers

Shared memory between 2 processes (applications)

I can't find any useful answer for this question, although it has been asked in a different way several times. I want to share a memory between two processes (two different applications), so that one of them can write to that memory and the other…
Tea Bee
  • 401
  • 2
  • 8
  • 18
22
votes
3 answers

How to get piped input to ruby -e on command line?

I'm trying to figure out how to write one liners on the bash console and pipe to ruby but I can't figure out how to get the input. This isn't working: echo "My String" | ruby -e "#{STDIN.read.first.downcase}" How can I get the piped input in ruby?
pixelearth
  • 13,674
  • 10
  • 62
  • 110
22
votes
2 answers

How do i diff two files from the web

I want to see the differences of 2 files that not in the local filesystem but on the web. So, i think if have to use diff, curl and some kind of piping. Something like curl http://to.my/file/one.js http://to.my/file.two.js | diff but it doesn't…
poolsideDev
  • 390
  • 4
  • 13
22
votes
3 answers

Command working in terminal, but not via QProcess

ifconfig | grep 'inet' is working when executed via terminal. But not via QProcess My sample code is QProcess p1; p1.start("ifconfig | grep 'inet'"); p1.waitForFinished(); QString…
ScarCode
  • 3,074
  • 3
  • 19
  • 32
21
votes
3 answers

Chain of piped commands, each outputting status to standard error

I have a chain of piped commands in a bash script, piping standard output to standard input: prog1 | prog2 | prog3 and they each output something to standard error. Some of them output overwriting the previous line, some do not, some do both: e.g.…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
21
votes
4 answers

popen implicitly declared even though #include is added

This is tiny snippet of my code. #include #include #include #include #include #include #include #include #include
Chris Allen
  • 653
  • 4
  • 9
  • 17
21
votes
5 answers

Hudson : "yes: standard output: Broken pipe"

I need to run a shell script in hudson. That script needs an answer from the user. To give an automatic answer I did the following command line :   yes | ./MyScript.sh This works well in Ubuntu terminal. But when I use the same command in the…
Farah
  • 2,469
  • 5
  • 31
  • 52
21
votes
4 answers

What are the differences between pipes in Windows and Linux?

What are the differences between pipes in Windows and Linux?
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
21
votes
2 answers

Is there any difference between socketpair and pair of unnamed pipes?

I would like to know not only user-side differences, but differences / common parts in Linux kernel implementation as well.
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
21
votes
2 answers

Is there a way to improve performance of linux pipes?

I'm trying to pipe extremely high speed data from one application to another using 64-bit CentOS6. I have done the following benchmarks using dd to discover that the pipes are holding me back and not the algorithm in my program. My goal is to…
KyleL
  • 1,379
  • 2
  • 13
  • 35
20
votes
2 answers

Piping input into a c++ program to debug in Visual Studio

this has probably been asked before, but I haven't been able to find any answers so far. I'm trying to start my program up with multi-line input, I.E. something I don't want to type in the command line every time (as I'd probably make a mistake). I…
Caleb Jares
  • 6,163
  • 6
  • 56
  • 83
20
votes
5 answers

Piping mysqldump to mysql

Sometimes I need to copy MySQL database (db1) to another database (db2). I found this command to be concise and effective: mysqldump --opt db1 | mysql db2 It was working fine, but now it breaks with following error: ERROR 1064 (42000) at line…
parserr
  • 729
  • 1
  • 5
  • 15
20
votes
3 answers

Overlapped I/O on anonymous pipe

Is it possible to use overlapped I/O with an anonymous pipe? CreatePipe() does not have any way of specifying FILE_FLAG_OVERLAPPED, so I assume ReadFile() will block, even if I supply an OVERLAPPED-structure.
MobyDX
  • 1,480
  • 1
  • 12
  • 13
20
votes
6 answers

How to use Windows CMD pipe( | ) feature with CALL :Label command option?

I have a frustrating problem when I want to use the pipe(|) feature with the Window's CMD shell's CALL :Label option. I have a very small example (below): call-test.cmd and sample output. The nub of the issue was/is to pipe the output of a CMD…
will
  • 4,799
  • 8
  • 54
  • 90