Skip to main content

All Questions

1 vote
1 answer
3k views

How output one command with tee to standard ouput and also to pipe it to another command?

Maybe this is duplicate, I have not found any answers though, but how to use pipe to output one command to multiple outpus (e.g. send it to pipe, stdout, or command substitution)? I have this line: $ ...
Herdsman's user avatar
  • 350
0 votes
1 answer
2k views

echo, pipe and command substitution

I want to substitute an echo command followed with | (pipe). For example, $(echo "echo 'hello' | cat") returns 'hello' | cat I expect this to behave like echo 'hello' | cat which returns hello but ...
xafizoff's user avatar
  • 113
3 votes
2 answers
1k views

Difference between piping and command expansion

This link is relevant What's the difference between substitution and piping to bash but I am not quite understanding everything that is being said. What is the difference between piping command1 ...
RhythmInk's user avatar
  • 561
5 votes
1 answer
350 views

Pipelined Sed does not work on found filename inside Bash command substitution when invoked from Find "-exec" [duplicate]

It looks like 'find', 'bash' and 'sed' in some cases does not work as one expects. The following example should first create file 'sample.txt', then find the file and finally process it by '-exec' ...
Venca B Spam's user avatar
3 votes
2 answers
2k views

blocking/non-blocking pipes/redirects inside command substitution

I observed the following behaviour in bash: { echo 'foo' ; sleep 10 ; } -> standard output "foo" appears immediately, after 10 seconds the command is done (as expected) { echo 'foo' ; sleep 10 ; } &...
user19426's user avatar
  • 133
0 votes
1 answer
474 views

capturing subshell command substitution output

I'm trying to capture the output of a command substitution. This works until a pipe is added to the command. Am I doing something wrong or is this a quirk of mingw? $ bash --version GNU bash, version ...
Donald Byrd's user avatar
3 votes
3 answers
2k 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 ...
Stphane's user avatar
  • 341
0 votes
3 answers
117 views

Saving a piped value went wrong

I installed jq to handle some JSON with bash. But somehow piping the JSON string to jq in combination with saving it's output to another variable went wrong. TEST='{"foo": "bar"}' PB_SIG=$TEST | jq '....
Milkmannetje's user avatar
3 votes
1 answer
3k views

Why doesn't PIPESTATUS work on pipelines within a command substitution

Proof below: Bash 4 Prompt> $(echo hello|sed 's/h/m/'|xargs -I{} ls {} 2>/dev/null|sed 's/ /_/') Prompt> for i in ${PIPESTATUS[@]}; do echo $i;done Output> 0 Prompt> echo hello|sed '...
Gregg Leventhal's user avatar
7 votes
2 answers
1k views

"command | less" vs "less <(command)"

A common "idiom" for viewing large amounts of command output is to pipe it to less, via command | less. However, it's also possible (perhaps only in bash, haven't tested in other shells) to use the ...
Drew McGowen's user avatar
6 votes
2 answers
6k views

Piping to the command substitution of a string containing pipes

This works— $ x='grep a' $ echo ab | $x ab This doesn't— $ x='grep a | grep b' $ echo ab | $x grep: |: No such file or directory grep: grep: No such file or directory grep: b: No such file or ...
Andrew Cheong's user avatar