Questions tagged [pipe]
A Unix pipe connects file descriptors of two processes. A pipe is created with the POSIX pipe() function declared in <unistd.h>. Shells provide pipe creation between processes using "|".
1,888 questions
0 votes
1 answer
58 views
`xargs sh -c` not picking up last argument (vs `for i in $(...)`) [duplicate]
I just wanted to build a simple bash script that inverted a 'hex color code' (made up of 3 pairs of 2-digit hexadecimal numbers, in the format #RRGGBB). In my first code block I attempt to perform ...
9 votes
4 answers
666 views
How can we get tar to respect SIGKILL like it used to?
From time to time I need to do a quick check of contents of an Ultrium tape, which can store even 6TB of data. To avoid reading the entire tape, I used to perform following procedure (in a loop): $ ...
3 votes
1 answer
218 views
grep does not work on output from `dnf check-release-update`
I'm using Amazon Linux 2023 dnf check-release-update --version-only 2023.9.20251027 2023.9.20251105 now I want grep output but it does not work dnf check-release-update --version-only | grep "...
2 votes
5 answers
893 views
How to use a "grep" result as an input of another grep, resulting in multiple lines?
I have built a Visual Studio solution, containing 92 projects. While building them, I get the following line for every one of them: 10>------ Rebuild All started: Project: HostLinkSw, Configuration:...
4 votes
2 answers
545 views
how to tell, from the outside, if the output stream of a process has been closed?
Suppose you have this script, on an Ubuntu machine: #!/bin/env python3 import sys import time try: i = 1 while True: print(i) i += 1 except Exception as e: sys.stderr.write(f"We ...
0 votes
0 answers
35 views
Why does `<command> | tee /dev/tty | :` (where `:` is the "no effect" or "does nothing" bash builtin) display nothing? [duplicate]
I wanted to use tee /dev/tty to look into the stream passing through a pipeline. While making some tests, I observed the following: ~$ cd /proc/self/fd /proc/self/fd$ ls 0 1 2 255 # Ok /proc/self/...
3 votes
1 answer
460 views
Understanding file descriptors and pipes resulting from `cat <(<command>)`
I don't understand the following: $ cat <(sleep 60) & jobs -l [1] 63813 [1]+ 63813 Running cat <(sleep 60) & /proc/63799/fd$ ps --forest PID TTY TIME CMD ...
-1 votes
1 answer
112 views
Serving a file (e.g. in Apache) from a named pipe (made with mkfifo)
Let's say I use Apache, and that I am in /var/www/html/. I do: mkfifo test.tar tar cvf - ~/test/* > test.tar & In a browser, when trying to download http://localhost/test.tar I get: ...
0 votes
0 answers
42 views
How can I grep the output of ffprobe? [duplicate]
I'd like to only see those lines containing "Stream #" from an ffprobe output. But whatever I do, it continues to show the whole output. Neither "|" nor ">" pipes work....
5 votes
3 answers
574 views
Can grep output the complete input verbatim only if there was a match?
I'm processing input data in a pipeline consisting of several programs. In one step of the pipeline, I want to know if there are certain lines in the input, but I want to output everything as-is ...
0 votes
2 answers
102 views
One-liner piping from find/xargs with paths including spaces
The following question likely does not relate specifically to Vim. I use a Vim example, as this is where I encounter the issue. Working on Ubuntu, I often open multiple files in Vim using tab pages: $ ...
10 votes
3 answers
2k views
bash: echo "hello" | > file.txt results in an empty file
I use the Git Bash on Windows, and stumbled over a strange behaviour. When I execute this command, it creates an empty file: echo hello | > hello.txt (hello.txt is empty after this command) I ...
0 votes
2 answers
211 views
How can I run if statements on a command output without terminating it?
I have to run four separate if statements (and their consequences) on one command output continuously as it updates (doing four different things based on four different strings which might be in the ...
0 votes
1 answer
121 views
What is (if any) the file descriptor of /dev/tty?
The urgent issue to read keyboard input in the pipeline is solved by the answer in https://stackoverflow.com/questions/15230289/read-keyboard-input-within-a-pipelined-read-loop: mycommand-outputpiped |...
3 votes
2 answers
191 views
What explains this very odd behavior of GNU grep interacting with buffering and pipes and how to stop it?
This is best illustrated with an example I feel: { printf 'foo\nbar\n' ; sleep 2 ; } | grep -m1 foo { printf 'foo\n' ; sleep 2 ; printf 'bar\n' ; sleep 2 ; } | grep -m1 foo Both of these commands, ...