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

3
votes
2answers
29 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
51 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
48 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
50 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
23 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
34 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
47 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
22 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
557 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
51 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
35 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 ...
-1
votes
0answers
33 views

Bash script not quite working

First of all I am new to scripting / programming of any kind so have very basic understanding. I found this script and it does what I want it to do, except at the end I can't send the variable $msg to ...
0
votes
1answer
30 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
37 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
51 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
23 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
42 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
30 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
41 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
33 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
62 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
98 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
33 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
27 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
28 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
68 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
24 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
39 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
51 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
52 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
38 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
45 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
59 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
562 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 ...
3
votes
3answers
49 views

redirecting output of a command as if it was file input

I find myself always having to arrow up and going backwards through the command line to change one part of an earlier command that is pipped to a later grep or head or whatever command. For a crude ...
3
votes
2answers
45 views

How to pin certain files when using sort?

Normally I am more creative with Unix commands and pipes, but not today. So what I have is this: collage.jpg DCIM001.jpg DCIM002.jpg or this: 001.jpg 002.jpg boston-collage.jpg or sometimes ...
-4
votes
1answer
61 views

What does “|” between arguments in cat command do?

I understand what the "cat" command does. I.e. cat file1 file2 > file3 Will put the contents of file1 and file2 in file3. (If I am not mistaken) But what exactly does: cat file1 | file2 > ...
1
vote
1answer
33 views

Why is there an error when grepping man results?

I am running this command, attempting to grep the output, but I keep receiving this error and I don't understand why. man man | grep color <standard input):977: warning [p 8, 0.8i, div ...
0
votes
0answers
15 views

how to always add the same text at the end of a command automatically? [duplicate]

I am usine dict server and wanted to have the result as pages so my command will be : dict word | pg How can I automate this so that every time I use dict, "| pg" is added at the end of the ...
3
votes
1answer
300 views

Process not closing when stdin is closed

I am starting a process with a program. I expect the process to terminate when the program does, since it loses its stdin. I terminated the program, then went to the proc/pid/fd for the process, ...
7
votes
1answer
258 views

How can I pipe only stderr in zsh?

In bash: $ echo hi 2>&1 1>/dev/null | cat $ While in zsh: $ echo hi 2>&1 1>/dev/null | cat hi $ Is there a way to pipe only standard error while redirecting standard out?
1
vote
2answers
741 views

How to append a line in a zipped file without unzipping?

mknod /tmp/oracle.pipe p sqlplus / as sysdba << _EOF set escape on host nohup gzip -c < /tmp/oracle.pipe > /tmp/out1.gz \& spool /tmp/oracle.pipe select * from employee; spool off ...
3
votes
2answers
63 views

less command with pipe

I learn that pipe (|) is used to pass stdout into subshell's stdin. But, command less must have filename argument like less file1.txt However, when I use command like ls -l /root | less, it works. ...
0
votes
1answer
30 views

Pipe encrypted archive to uploader

Assume, I do archive several files with this functions: gen_password () { gpg --gen-random 1 "$1" | perl -ne' s/[\x00-\x20]/chr(ord($^N)+50)/ge; ...
3
votes
2answers
54 views

Ways to optimize performance in pipelines over network (RSH and SSH)

Consider a data transfer over a pipeline network in legacy systems with remote shell (RSH), like: rsh host -l user tar -cf - /home/dir \| compress | uncompress | tar -xvf - and this one in 'modern' ...
2
votes
3answers
68 views

Processing a single file as both input and output throughout pipes [duplicate]

Good evening, I would like to filter a file's content with some piped commands and then write the result back to the same file. I know, I can't do that the way I wrote it. Hold on … This is the ...
1
vote
2answers
39 views

How to enforce set -o pipefail on failing first command in pipe

I am trying export data from a postgres database to a file in bash. But I would like to make sure that the file is only overwritten if the connection to the database doesn't fail (i.e. I get some data ...
1
vote
2answers
48 views

pipe does not write to file [duplicate]

I want to get only the number of ms from a ping command to a file Without piping to a file it works as intended. I'm a little bit lost on why > to a file does not write anything. This works: ping ...