Difference between revisions of "Exec"
Jump to navigation
Jump to search
↑ https://askubuntu.com/questions/525767/what-does-an-exec-command-do
Line 10: | Line 10: | ||
https://unix.stackexchange.com/questions/61931/redirect-all-subsequent-commands-stderr-using-exec | https://unix.stackexchange.com/questions/61931/redirect-all-subsequent-commands-stderr-using-exec | ||
− | |||
− | |||
− | exec > >(tee "$HOME/somefile.log") 2>&1 | + | [[#!/bin/bash]] - |
− | + | ||
− | echo "$HOME" | + | exec > >(tee "$HOME/somefile.log") 2>&1 |
− | echo hi | + | |
− | date | + | echo "$HOME" |
− | date +%F | + | echo hi |
− | echo bye 1>&2 | + | date |
− | + | date +%F | |
+ | echo bye 1>&2 | ||
== Related commands == | == Related commands == |
Revision as of 11:40, 2 February 2023
https://man7.org/linux/man-pages/man1/exec.1p.html
Open YOUR_FILE_TO_READ as file descriptor 3 for reading: exec 3< YOUR_FILE_TO_READ
exec $SHELL
https://unix.stackexchange.com/questions/61931/redirect-all-subsequent-commands-stderr-using-exec
#!/bin/bash - exec > >(tee "$HOME/somefile.log") 2>&1 echo "$HOME" echo hi date date +%F echo bye 1>&2
Related commands
shopt -s execfail
See also
- Standard streams:
/dev/stdin
,/dev/stdout
,/dev/stderr
,/dev/null
, File descriptor,set -x, 2>&1, stdbuf
Bash [ -c ]
,alias
,&&
, Bash history, Autocompletion,set
,unset
,export
,.bash_aliases, .bashrc and .bash profile
,PS1
,echo
,brace expansion
, Function,shopt
,trap
,set -e
,source
,PATH
,complete
,disown
,.hushlogin
,.bashrc
,builtin
,eval
,set
,$PATH
,$HOME
,TZ
,.profile
,-e, -i
,Builtin (Bash)
,mapfile
,~
, return (Bash), for, until,declare, dirname, basename, functions.sh
, Bash arithmetic expansion,shift, bash --rcfile, readonly, $1, $@
Advertising: