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
41
votes
5 answers

Angular - Observable with async pipe used multiple times in template... Good Practice or Bad?

If I have the need to bind multiple properties from the same observable within my component template... For example: ... ...am I…
Mark
  • 486
  • 1
  • 4
  • 10
41
votes
3 answers

equivalent of pipefail in dash shell

Is there some similar option in dash shell corresponding to pipefail in bash? Or any other way of getting a non-zero status if one of the commands in pipe fail (but not exiting on it which set -e would). To make it clearer, here is an example of…
Lavya
  • 1,475
  • 2
  • 17
  • 21
41
votes
4 answers

How does a pipe work in Linux?

How does piping work? If I run a program via CLI and redirect output to a file will I be able to pipe that file into another program as it is being written? Basically when one line is written to the file I would like it to be piped immediately to…
Jon
40
votes
3 answers

Why does delayed expansion fail when inside a piped block of code?

Here is a simple batch file that demonstrates how delayed expansion fails if it is within a block that is being piped. (The failure is toward the end of the script) Can anyone explain why this is? I have a work-around, but it requires creation of a…
dbenham
  • 127,446
  • 28
  • 251
  • 390
40
votes
4 answers

Pipe vs. Temporary File

Is there a big performance difference between: Process A writing to a temp file, and process B reading that file Process A writing to a pipe, and process B reading from that pipe I'm curious to know what the answer is for both Windows and…
Matt Fichman
  • 5,458
  • 4
  • 39
  • 59
40
votes
11 answers

How to display the currency symbol to the right in Angular

I have to display Euro currency like this : 583 €. But with this code: {{ price | currency:'EUR':true }} I get €583, is there any option in Angular core to move the symbol to right? A lot of european countries use the symbol at the right (France,…
Ekaitz Hernandez Troyas
  • 1,147
  • 2
  • 11
  • 18
39
votes
5 answers

How to run " ps cax | grep something " in Python?

How do I run a command with a pipe | in it? The subprocess module seems complex... Is there something like output,error = `ps cax | grep something` as in shell script?
eugene
  • 39,839
  • 68
  • 255
  • 489
39
votes
3 answers

Can someone explain Ruby's use of pipe characters in a block?

Can someone explain to me Ruby's use of pipe characters in a block? I understand that it contains a variable name that will be assigned the data as it iterates. But what is this called? Can there be more than one variable inside the pipes? Anything…
Josh Curren
  • 10,171
  • 17
  • 62
  • 73
39
votes
8 answers

How to pipe input to sublimetext on linux?

How do I receive text from stdin into sublimetext editor? With vim it works like this: echo "potato potato potato" | vim - The same thing works with gedit, creating a new document with the contents. Sublimetext seems to just start editing a file…
wim
  • 338,267
  • 99
  • 616
  • 750
38
votes
6 answers

How to get data from command line from within a Python program?

I want to run a command line program from within a python script and get the output. How do I get the information that is displayed by foo so that I can use it in my script? For example, I call foo file1 from the command line and it prints…
user1058492
  • 561
  • 2
  • 5
  • 9
38
votes
3 answers

Pipe output to two different commands

Possible Duplicate: osx/linux: pipes into two processes? Is there a way to pipe the output from one command into the input of two other commands, running them simultaneously? Something like this: $ echo 'test' |(cat) |(cat) test test The reason…
Malvineous
  • 25,144
  • 16
  • 116
  • 151
37
votes
4 answers

using a Bash variable in place of a file as input for an executable

I have an executable that is used in a way such as the following: executable -v -i inputFile.txt -o outputFile.eps In order to be more efficient, I want to use a Bash variable in place of the input file. So, I want to do something like the…
d3pd
  • 7,935
  • 24
  • 76
  • 127
37
votes
3 answers

How to create a named pipe in node.js?

How to create a named pipe in node.js? P.S.: For now I'm creating a named pipe as follows. But I think this is not best way var mkfifoProcess = spawn('mkfifo', [fifoFilePath]); mkfifoProcess.on('exit', function (code) { if (code == 0) { …
wako
  • 785
  • 2
  • 7
  • 9
36
votes
3 answers

What does |> (pipe greater than) mean in R?

I have recently come across the code |> in R. It is a vertical line character (pipe) followed by a greater than symbol. Here is an example: mtcars |> head() What is the |> code doing?
Ian Campbell
  • 23,484
  • 14
  • 36
  • 57
36
votes
2 answers

titlecase pipe in angular 4

Angular 4 introduced a new 'titlecase' pipe '|' and use to changes the first letter of each word into the uppercase. The example as,

{{ 'ramesh rajendran` | titlecase }}

Is it…
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234