A Unix pipe connects file descriptors of two processes. A pipe is created with the POSIX pipe() function declared in . Shells provide pipe creation between processes using "|".

learn more… | top users | synonyms

0
votes
0answers
33 views

How to do multi threading using mkfifo? [on hold]

I have a file which having milions of records like below. 8350000014|1234567|NULL|NULL 7336004920|478637|NULL|NULL 9876006473|478632|NULL|NULL 6730000012|1234567|NULL|NULL ...
0
votes
0answers
29 views

When was pipelining introduced?

I understand early versions of Unix were licenced from AT&T to Universities and ran on PDP computers. I read in Tanenbaum's book (operating systems) that the first versions of Unix were only a ...
8
votes
1answer
70 views

Why doesn't file redirection to and from a named pipe work, but piping to cat does?

This is a simple echo server in Unix, using nc: mkfifo fifo cat fifo | nc -k -l 4458 -v | cat >fifo (based on this) As I can see it, the data flow works as follows: fifo (my named pipe) | | ...
4
votes
3answers
461 views

How do pipes and infinite streams work?

I usually use command1 | command2 | command3 a lot in Linux but most of them are dealing with definite content. When I tried this with an infinite stream cat | sed '' | sed '' which hopefully ...
0
votes
1answer
28 views

how to color specific strings in standard output and standard error [duplicate]

How do you color specific strings in standard output and standard error? For example: gpg --verify Outputs either a good signature or a bad signature string. How can I color the good one, green; ...
1
vote
1answer
42 views

Persistent process substitutions? [duplicate]

Is there a way to take a process substitution like <(grep foo some/file), and save it to a "file-like entity" on disk (reminiscent of a fifo), so that, every time this thing was opened for reading ...
0
votes
1answer
35 views

globbing and wildcards

Are wildcards ever supposed to be expanded for a program that is not the first in the pipeline? Every example uses wildcard for the first program in the pipelilne. For example, the following does ...
3
votes
2answers
37 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with ...
1
vote
1answer
42 views

Filter out duplicate lines of tail -f [duplicate]

I often need to tail -f apache access logs for websites to troubleshoot issues- one thing that makes it annoying is that anyone loading a page once may cause 12+ lines to get written to the log, and ...
20
votes
4answers
1k views

How to invoke vim editor and pipe output to bash

Sometimes I need to write text and then pipe that text into another command. My usual workflow goes something like this: vim # I edit and save my file as file.txt cat file.txt | pandoc -o file.pdf # ...
1
vote
0answers
7 views

Track amount of data application and a device file are exchanging

Is it possible to track how much data is going into a device file and an application as a third person? Background A web server is communicating with a device /dev/ttyACM0. The server offers a HTTP ...
2
votes
2answers
137 views

How do I double each line of piped output? [duplicate]

How do I double each line of input piped in? Example: echo "foobar" | MYSTERY_COMMAND foobar foobar
0
votes
2answers
28 views

operate on different sections of stdin without intermediate file

Is there a simple way to do this with redirection or pipes without creating FILE1? I want to apply process2 to the body of the output of process1, without touching the first and last few lines. ...
0
votes
1answer
31 views

How to determine if it is a fault of the Network Card?

Basically, I have a PC having problems. Let's call it POO. POO is a pc running Gentoo Linux, with KDE. It is quite freshly setup on an old hardware. So far I do not notice it has other problems, ...
8
votes
5answers
457 views

Is there a tool to dynamically redirect output to a new file on request

I'm currently redirecting the output of a monitoring tool to a file, however what I'd like to do, is to redirect this output to a new file on my request (using a keybinding), without stopping the said ...
3
votes
2answers
31 views

Chaining Linux terminal commands

I have a function that has my EV3 speak speak(){ espeak -a 200 -s 130 -v la --stdout "$@" | aplay; } it works by simply speak "Say this" I want it to say the contents of a file, so I have this ...
0
votes
1answer
53 views

grep with piping and showing multiple lines

I am trying to use grep to search a large text file, and return the paragraph containing a few key words. I also want to return the surrounding lines in the result. So, for example I have the ...
5
votes
1answer
53 views

Cannot grep jobs list when jobs called in a function

I can grep the output of jobs, and I can grep the output of a function. But why can't I grep the output of jobs when it's in a function? $ # yes, i can grep jobs $ jobs [1]+ Running vim ...
0
votes
0answers
7 views

Why can't I pipe my ruby script into lemonbar? [duplicate]

If I try to pipe this ruby script: while true puts "hi" sleep(1) end into lemonbar it does not work. Lemonbar displays nothing. If I run lemonbar manually and type in things, it works just ...
1
vote
2answers
55 views

Grep command using contents of a heredoc

I'm creating a script to update a remote computer and I want to know if any user is using the computer before I update. I have a list of users and I created a heredoc with all of them. The command I'm ...
1
vote
1answer
24 views

Piping output between two simultaneous, independent programs

Let's say I have two programs which play chess: chess_1 and chess_2. They keep track of the board themselves, and take as input opposing moves, and then output their moves. For example, if I wanted to ...
0
votes
1answer
38 views

send signal to command pipe tears down whole pipe

I have a simple example of two processes the first is a simple loop which does some processing #!/bin/bash function signalHandler() { echo "sig: $1 received ==> exit" for i in {1..5}; do ...
1
vote
1answer
61 views

Check if the files in a specific directory have the proper extension?

I have created a script that will create a few directories and then organize other files from one directory by moving them into specific sub-directories based on their extension (i.e. .gif in media, ...
-3
votes
1answer
30 views

How to do inter process communication using single bidirectional pipe in linux?

How do 2 processes communicate by using single bidirectional pipe, such that both the ends of the pipe could read and write. I have an assignment to do, kindly help me with this.
15
votes
2answers
561 views

How do I use grep while keeping the original text color? [duplicate]

For example, I have a output: Hello, this is the output. (let's say that for example hello is colored red, and the is colored green, and output is colored purple). Now, let's say that this is the ...
1
vote
2answers
64 views

Read files from directory and organize them by extentsion into corresponding folders

I'm trying to create a bash function script that will allow me to create multiple directories with the names below. I'm also trying to organize files by extension into their corresponding folders ...
3
votes
1answer
38 views

Standard/canonical way to test whether foregoing pipeline produced output?

The situation I have in mind has the following structure: % some_command | [PRODUCED OUTPUT] || echo 'no output' >&2 Here [PRODUCED OUTPUT] stands for some as-yet-unspecified testing ...
0
votes
1answer
35 views

Cygwin - tail stops reading input pipe after first write

I have the following script to run my application in Ubuntu with redirecting its input (where $in is named pipe which is used to send text lines to stdin). tail -f "$in" | "$app_bin" $app_args & ...
3
votes
2answers
42 views

pipe process output to command split by line and whitespace

On the system I'm using I often need to cancel jobs I run. I can check my jobs like this: $ showq|grep jquick 2001744 jquick Running 120 00:08:26 Mon Apr 11 11:06:02 2002020 ...
3
votes
4answers
55 views

Search within a search

I've gotten used to using grep for my command line searches and wanted to know how to successfully do a search using the result of another search. Here's my attempt, where I am looking for 'tool' ...
0
votes
1answer
33 views

tar: option requires an argument — 'f'

I am trying to download content by following this tutorial. But when I use the following code from the tutorial: curl https://start.spring.io/starter.tgz -d style=web -d name=simple | tar -xzvf ...
1
vote
1answer
46 views

How to get `yum list` output to stay on one line when getting output via remote ssh command?

When I SSH to a machine with ssh machine and run yum list it outputs everything that's installed as expected, and importantly every item is on one line like so: xz-devel.i386 ...
1
vote
1answer
39 views

Can't pipe into netcat

I have a squid proxy running in a docker container, started like this: docker run --privileged -d --publish=3128:3128 --name foo squid I want to get some information from it, from another container ...
0
votes
2answers
50 views

Piping sed/grep output does not work

If I run the commands bellow, only out1 has output, the out2 and out3 are empty. # this is just to generate a self-signed certificate openssl genrsa -out /tmp/ssl.key 2048 openssl req -sha256 -new ...
1
vote
2answers
46 views

sox in between two pipes

I'm trying to put the "sox" utility in a two pipes command to resample a mono 44kHz audio file to a 16kHz audio file. It works fine with a single pipe : $ speexdec toto.oga - | sox -V -t raw -b 16 ...
3
votes
2answers
70 views

avoid multiple pipes broken due to missing command

In shell scripts I often use multiple pipes like this: cmd1 | cmd2 | cmd3 Now if cmd2 is missing the pipe will result "broken" and cmd3 won't receive any input. As workaround I could test ...
0
votes
0answers
28 views

Stop piping on error [duplicate]

Given the command mysqldump ... | gzip | base64, how can you stop the execution of the chain in case mysqldump exits with an unclean code instead of gzipping and base64 coding an error message?
3
votes
3answers
106 views

Direct output to pipe and stdout

I was wondering if there is a way to pipe the output of a command and direct it to the stdout. So for example, fortune prints a fortune cookie and also copies it to the clipboard: $ fortune | tee ...
0
votes
1answer
36 views

Copy process output few lines to a file

I want to copy the xinput-calibrator output to the temp.txt file from my Qt application. I am starting the QProcess from the Application Using the command xinput_calibrator | tee log.txt, I am ...
0
votes
1answer
31 views

the T-split command in linux as opposed to cat? [duplicate]

so for a question I have to store both messages of x and y to log, since y only exists and x does not I used cat x y &> log to be able to store both messages. However as the second part my ...
1
vote
1answer
45 views

`docker logs foo | less` isn't searchable or scrollable but `docker logs foo 2>&1 | less` is

Using either one gives readable text. But only with the stderr redirect can one scroll or type /somepattern and get matches. Without it searching gives "Nothing to search (press RETURN)" and a ...
0
votes
3answers
98 views

Why is the array empty after the while loop? [duplicate]

I try to initialize an array in bash-4.2 next way: ring=() ls -las | tail -n +4 | while read line > do > ring+=("$line") > echo ${ring[-1]} > done 3924 -rw-r--r-- 1 username group 4015716 ...
1
vote
1answer
25 views

Executing shell script parallelly and in background skips some operation

del_client.sh --delete client1 & del_client.sh --delete client2 & del_client.sh --delete client3 & del_client.sh --delete client4 & When I executed the commands above in the ...
1
vote
1answer
51 views

How to pipe html into lynx?

I am testing some ajax call from the console. I like get rid of the meta-information noise that is html markup and just read the content, hence I like to pipe it into a terminal browser, e.g. lynx. ...
0
votes
0answers
52 views

Is a pipeline made of simple commands?

From Bash Reference Manual A pipeline is a sequence of simple commands separated by one of the control operators | or |&. From POSIX 2013 A pipeline is a sequence of one or more commands ...
1
vote
4answers
56 views

Why does read with pipeline fail in an ssh session?

Why does this show blank lines instead of folders found by find? ssh -o stricthostkeychecking=no -o userknownhostsfile=/dev/null \ -o batchmode=yes -o passwordauthentication=no user@myserver.xx \ ...
4
votes
2answers
41 views

Terminate a text search in less(1) and continue to read thru a Unix pipe

gunzip < 100terabytes.txt.gz | less less(1) reads as many lines as necessary to fill your screen and then stops to read(2). As a result, gunzip(1) is blocked on write(2) as the pipe becomes ...
1
vote
1answer
47 views

Why don't the SHA's match?

I am trying to write a script and it uses the SHA of a date but I am getting two different results and for the life of me can't figure out why. echo -n 03112016 | cut -d'.' -f4 | sha256sum | cut -d' ...
0
votes
2answers
60 views

How can I clear/empty a file being piped to?

Say I have some process which pipes to a file: yes > foo I know want to clear/empty the file foo, but still want the process to write to the file, i.e. start filling the file again after ...
9
votes
1answer
564 views

How does a pipeline knows when to stop [duplicate]

Some programs can have an infinite runtime and produce infinite output. When used in a pipe with a command that finish, how does the pipeline knows when to stop ? For instance, take yes (infinite ...