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

1
vote
1answer
51 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
49 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
55 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
68 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
75 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
110 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
44 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
70 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
167 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
65 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
63 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
43 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 full....
1
vote
1answer
48 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
61 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
571 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
60 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
68 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
36 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 '3tbd1,0'...
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
377 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
326 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
795 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
81 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
34 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; s/([\x7E-\xDB])/chr(ord($^N)-93)/...
3
votes
2answers
84 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
72 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
52 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
50 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 ...
0
votes
1answer
25 views

Piping difference of grep -c's with different regex to bc

I need to find the number of words in a file (1 word per line) that do not contain some set of letters. To do this I want to take the difference of grep -c '.' <file> and grep -c '<...
1
vote
1answer
38 views

How to assign a variable within a pipe

I'm building a one liner in bash. If making a script or writing temp files were an option, I wouldn't need to ask. I need to assign a variable in the middle of a set of pipes to use down the line. ...
1
vote
0answers
21 views

Pipe output of process that's already running

I've got a process that spews out a lot of output, and it's going to be running for the next hour. I forgot to pipe its output through my awk script before I started running it. Now my terminal is ...
0
votes
2answers
310 views

Bash - Redirect output to a variable or file descriptor, then read from the variable or file descriptor

Here's an example of a bash script that redirects all output to a file (and shows output on the screen too): # writing to it exec > >(tee --ignore-interrupts ./log) exec 2>&1 echo "here ...
1
vote
1answer
122 views

patch: “bad file descriptor” in combination with pipe and LD_PRELOAD/ libtrash

Very short summary: cat "$file" | patch produces a Bad file descriptor-error, but patch < "$file" works, when libtrash is preloaded with LD_PRELOAD, and only on bigger projects. Description: For ...
0
votes
1answer
38 views

what is the correct form for “tex file.tex | dvips | ps2pdf”?

I would like to streamline 3 commands into one, but I keep getting error message. tex | dvips | ps2pdf file.tex or possibly tex file.tex | dvips | ps2pdf Then divps says there is no file. Or I ...
1
vote
3answers
36 views

How do I organize and cut this portion of a directory into a file?

I'm new to unix and I'm not sure how to name my title but my main objective is to copy the contents of a directory and send it to a file. Then cut out the directory location to just have the name. ...
3
votes
2answers
155 views

Trace a binary stream from a device file

I'm debugging a binary stream that is coming from a device file. I would like to have the output printed out in real time as hex values. So far I've used tail -f /dev/ttyAPP2 | hexdump -C but after ...
2
votes
2answers
65 views

Read a password securely from within process substitution?

Related: Securely feeding a program with a password How to read from stdin in process substitution? Process substitution and cat: can't read stdin I've read the above questions and I still can'...
3
votes
2answers
52 views

Piped commands performance in embedded Linux

Recently, we purchased a software solution to integrate into a device we're developing. There's plenty we need to modify and adapt to our needs, so today I was going through part of the code to see ...
6
votes
1answer
437 views

Using 'ping', 'cut' and 'tee' together

So, I understand that by using 'tee' I can redirect the output of a command such as 'ping' to stdout as well as a file. For example: > ping google.com | tee somefile This would display the ping ...
3
votes
3answers
61 views

How to pipe data from one command to another command which allows only a file as an argument?

I have some arbitrary data as an output of a command (e.g. a fragment of a binary data put out using tail). I want to feed it to another command/program which allows only a file as an argument (e.g. ...
0
votes
2answers
50 views

getting a list of all lowercase words in a file

I'm trying to get a list of all lowercase words in a file. This far I've gotten to the point of getting a list with the command line cat filename.txt | tr ' ' \\n | grep -w '[[:lower:]]*' | sort -u | ...
1
vote
2answers
94 views

How to run a program in a screen, redirect all output to a file and detach

Running a command in a screen and detaching is quite simple. screen -S test -d -m echo "output of command that runs forever" However I would also like to pipe all the output to a file for logging, ...
-1
votes
2answers
56 views

piping with grep

I want to search "C" in the grades column inside the file "input.csv": roll,name,total,rank,grade 001,A B,78,23,C 003,F YZ,100,1,* and what I'm trying is: cut -d"," -f4 input.csv | grep "C" ...
1
vote
3answers
75 views

Can I redirect the output of a program to cat with a pipe?

I have a folder with three files and basic contents: $ tail * ==> file1 <== file 1 contents ==> file2 <== file 2 contents ==> file3 <== file 3 contents I would like to see the ...
1
vote
0answers
167 views

Half-close netcat connection

How can I have a netcat connection terminate the sending half of a TCP connection if its input reaches EOF? I have a (non-standard) TCP service which reads all its input (i.e. until the client sends ...