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

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 ...
3
votes
3answers
55 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
63 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
35 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
333 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
279 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
764 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
73 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
33 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
67 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
70 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
46 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 ...
0
votes
1answer
23 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
35 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
260 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
93 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
35 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
130 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
62 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 ...
3
votes
2answers
43 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
429 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
57 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
49 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
85 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
65 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
145 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 ...
14
votes
3answers
1k views

In `dmesg | head`, (how) is dmesg being killed after 10 lines of output? [duplicate]

If I run these commands: dmesg | head -n 10 I presume the OS sends back some kind of signal to dmesg once head has read 10 lines. How does this work? What does head tell the kernel? This is ...
3
votes
2answers
40 views

Why builtin times doesn't work in pipeline?

I've the following sample script: #!/usr/bin/env bash sleep 5 printf "times cmd: " times printf "pipeline: " times | ( read user sys; echo $user; ) printf "head: " times | head -n1 printf "times cmd ...
5
votes
2answers
65 views

Understanding i/o redirection in the context of _process substitution_

Running GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu). I don't really understand process substitution (ProcSub) from the perspective of a user interested in lifting the hood on i/o ...
1
vote
2answers
21 views

Find unique lines based on only a section

I am wondering if there is a way to split lines by some character (E.g. :) and find unique lines based on one part of this split. For example if I had the following piped in via stdin file1: line 4 ...
1
vote
1answer
49 views

Broken pipe error when reading stops

I'm trying to make a quick & dirty bash function to compare the audio content of two FLAC files without decoding them into a temp file. With the flac command line tool I'm decoding each file into ...
2
votes
2answers
74 views

How to sort data stream by 2 column names (column number may vary)?

I get a stream of data from an API with which look like this: redID blueID whiteID 1 22 2 44 15 41 2 15 15 31 2 14 What I need to do, is to sort ...
1
vote
1answer
73 views

How to provoke a broken pipe

I try to debug a python script that interfaces MPD using python-mpd2. When the script tries to perform an action after being idle for a couple of hours, it terminates with an exception ...
1
vote
1answer
211 views

Get absolute path of file OS X

I am creating a script which will prompt the user to enter a location of file and it will convert it to an absolute path. This is what I have so far. I'm not sure how to append these together. ...
1
vote
1answer
35 views

Appending to a file suffix range with echo and tee

I am unable to figure out how to properly pipe and tee to append to a range of files. Instead of manually typing them out echo "help!" | tee >> file1 file2 file3 I am trying to figure out: ...
4
votes
1answer
120 views

Ctrl-c kills shell when pipeline is used in input redirection subshell

If I run a command like: cat <(echo 1 | pv) | pv cat <(echo 1 | pv) | less cat <(echo 1 | pv) | cat The command seems to run forever. Entering ^C (SIGINT) kills the entire shell instead ...
1
vote
2answers
96 views

cryptsetup: Attaching loopback device failed

I am using cryptsetup with detached header. For that I am using the --header parameter, to specify header file. I can open my device using: cryptsetup luksOpen /dev/sdb1 sdb1 --header LUKS-HEADER ...
1
vote
1answer
56 views

Unix awk decimal export in pipe

I'm struggling to adapt a script, which loops through a large number of individual files (subj_id), and prints out the value of $4 in a specified line. Text file contains lines # Measure Brain, ICV, ...
2
votes
1answer
54 views

gnuplot output of a pipe

Inspired by this question I tried to pipe output to gnuplot and then plot it. My pipe is: cat file.txt | grep CU | perl -e 'while(<>){print +(split)[3], "\n"}' | gnuplot file.gp Where ...
1
vote
1answer
42 views

Find files and send to a temp file

Vim does support a nice option to accept a file with list of files that are then opened in a Quickfix list. Rough example, I find all files in ~ that are smaller than 1KB and pass this to Vim: find ~ ...
16
votes
5answers
915 views

How to trick a command into thinking its output is going to a terminal

Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed ...
4
votes
4answers
155 views

Use awk interactively through a pipe

Looking at this question, I've noticed that awk can't read user input if the file is being piped into standard input, but it does behave as expected if reading input from a file given as a command ...
-1
votes
1answer
86 views

are named pipes (mkfifo) the predecessor of RabbitMQ? [closed]

Is RabbitMQ, for inter process communication, like pipes and named pipes? How does RabbitMQ compare to named pipes? Except distributed systems. (RabbitMQ, for those who haven't encountered it, is an ...
3
votes
2answers
177 views

Process each line of output from `ping` immediately in pipeline

I have a few examples of different ways of extracting timing information from ping -c 10 google.com. For some of these pipelines, a line of output is produces every so often, just like the output of ...