Skip to main content

All Questions

Tagged with
0 votes
2 answers
99 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 ...
Gridzbi Spudvetch's user avatar
0 votes
1 answer
42 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 |...
Martian2020's user avatar
  • 1,363
3 votes
2 answers
113 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, ...
Zorf's user avatar
  • 171
3 votes
2 answers
86 views

print_one_line_and_wait_long_time | head -n1: early exit of pipe/process substitution [duplicate]

tl;dr: How to reliably ensure that the pipe a | head -n1 terminates as soon as head terminates? Motivation: git log --grep="$MAIL_SUBJECT_LINE" --oneline --format=%H | head -n1 takes a long ...
teapot's user avatar
  • 361
1 vote
1 answer
48 views

Is it possible to pipe command output to fd3 of another process?

Normally, we can pipe stdout to stdin as follows: echo "This is going to stdout" | grep -o going Suppose instead of grep I wrote a script that reads from both stdin and fd3, and then ...
merlin2011's user avatar
  • 4,099
3 votes
3 answers
183 views

How to quit from a pipeline "command1 | command2" while keeping a background subprocess launched by command1 alive?

Regarding the command cmd1.sh | grep "message", in which cmd1.sh is as below #!/bin/bash echo "message from foreground father proess$(date)" setsid sleep 100 & echo "...
Qiu Yangfan's user avatar
0 votes
1 answer
48 views

watch with piped command executes differently than command itself

What am I doing wrong setting up following watch command? This works: ls -ltr ~/meteofetcher/data/metar/2024/12 | tail -10 | awk '{ print $9 }' | xargs -I {} grep 'LSZH' {} But this watch "ls -...
glades's user avatar
  • 117
0 votes
2 answers
86 views

Piping output to bash script

I'm going through the "sed & awk" book by Dougherty and Robbins. One of the examples calls for piping output to a shell script: sed -f nameState list | byState But I've found that, in ...
Mike's user avatar
  • 103
6 votes
1 answer
749 views

bash pipe loses data when command crashed

Consider this simple program (abort.py) that writes some text to stdout and stderr and then crashed (abort()). import os import sys print("end stdout") print("end stderr", file=...
lewisxy's user avatar
  • 171
3 votes
2 answers
1k views

How to pipe input to an interactive shell in Bash

I want to do something like this: echo whoami | sh The command whoami runs in sh, but because the pipeline as a whole runs in a subshell, the sh interpreter exits instead of giving me a shell prompt. ...
Alex Henrie's user avatar
3 votes
0 answers
131 views

Understanding piping to a unix domain socket in the background

I have a Debian 12 (bookworm) host where I run three VMs using QEMU / KVM. To simplify VM management, each VM has a QEMU monitor socket. These sockets are /vm/1.sock, /vm/2.sock and /vm/3.sock. Among ...
Binarus's user avatar
  • 3,809
7 votes
1 answer
688 views

FIFO capture using cat not working as intended?

Hi I am trying to use a Unix FIFO to communicate between a Python script and a shell script. The intention is for the shell script to capture all output of the python script. So far I have the ...
First User's user avatar
1 vote
0 answers
45 views

Bash: export does not work if preceeds a pipe redirection [duplicate]

Example 1 (export and tee): $ export var=1 | tee /dev/null $ echo $var $ Example 2 (null command between export and pipe): $ export var=1 && : | tee /dev/null $ echo $var 1 export sets var ...
Alexander Samoylov's user avatar
0 votes
2 answers
58 views

Difference in bash output redirections behavior

I am trying to understand the reason behind the difference in redirections of bash output. Here are two approaches: Redirection of the output to named pipe: /bin/bash -i 2>&1 1>/tmp/fifo ...
Pauloss's user avatar
2 votes
1 answer
76 views

Is there a way to `exec` a pipeline or exit shell after launching a pipeline?

I'm writing a shell wrapper script that is supposed to act as a pager (receiving input on stdin and performing output on a tty). This wrapper prepares environment and command lines, then launches two ...
intelfx's user avatar
  • 5,659

15 30 50 per page
1
2 3 4 5
38