New answers tagged io-redirection
5
votes
Accepted
"Ambigous Redirect" for redirecting text to a variable
Your config() function is never actually called in this snippet, so it will never be executed; therefore, those variables are never set. I think you meant to but accidentally put the call to config ...
8
votes
Why is using "|" or "&" provide different sizes of the result file?
Some of the details in this answer assume that the user uses a shell other than zsh. The details differ slightly for the zsh shell due to its MULTIOS feature.
strings *.bin > bin.txt | sort -n bin....
0
votes
How to make a variable from a subshell available in the parent shell
You can redirect your variable in a test.txt and get it in the parent shell.
testfn()
{
echo "test" > test.txt # redirect your variable in a test.txt
}
testfn & # execute your ...
0
votes
How to get color in terminal but no color in output file
You can remove colors from the file:
sed -e "s/\x1B[^m]*m//g" opfile
0
votes
Using a pipe with extra arguments at the end. Correctly directing the pipe instruction with multiple arguments
The solution was simpler than I expected:
To do this:
command1 -flag target.file | command2 -flag PIPEOUTPUT1HERE argument2
I used simply- to direct properly the output of the first command:
command1 ...
0
votes
How to redirect a list of human readable paths to another command?
Leaving command substitutions ($(...) or the `...` archaic form) unquoted invokes split+glob (split only in zsh) in Bourne-like shells.
The splitting is done on characters of the $IFS special ...
0
votes
How to redirect a list of human readable paths to another command?
If you want/need to pass the same line to multiple commands, something like this would work:
#!/usr/bin/env bash
T="${IFS}" # Save off the Internal Field Separator
IFS=$'\n' # Set it to ...
5
votes
Accepted
Bash redirection weird behavior
The EXIT trap is executed with the redirections that are in place when the trap is called. In your code, calling exit 1 in the main case statement causes the cleanup function to inherit the ...
7
votes
Accepted
feed output of command to another command as file
What you're looking for is called process substitution; it's not a standard feature of the shell, but supported in Bash/ksh/zsh. An example:
$ echo <(echo foo)
/dev/fd/63
$ cat <(echo foo)
foo
...
Top 50 recent answers are included
Related Tags
io-redirection × 1392bash × 538
shell × 362
shell-script × 198
pipe × 195
linux × 84
stdout × 81
file-descriptors × 76
command-line × 70
stderr × 69
files × 55
cat × 48
ssh × 42
stdin × 39
tee × 37
terminal × 35
zsh × 35
output × 35
grep × 31
cron × 31
text-processing × 28
sudo × 28
logs × 28
process-substitution × 27
scripting × 24