New answers tagged

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 ...
user avatar
  • 33.2k
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....
user avatar
  • 271k
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 ...
user avatar
  • 21
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
user avatar
  • 1,356
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 606
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 ...
user avatar
  • 271k
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 ...
user avatar
  • 116k

Top 50 recent answers are included