Difference between revisions of "Exec (Bash)"
Jump to navigation
Jump to search
↑ https://askubuntu.com/questions/525767/what-does-an-exec-command-do
(Created page with " <code>exec</code> in Bash <ref>https://askubuntu.com/questions/525767/what-does-an-exec-command-do</ref> == Related == exec == See also == * {{Ba...") |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | {{lc}} | ||
+ | |||
+ | <code>[[exec (Bash)|exec]]</code> in [[Bash]] <ref>https://askubuntu.com/questions/525767/what-does-an-exec-command-do</ref> | ||
+ | * https://manpages.ubuntu.com/manpages/trusty/en/man1/bash.1.html | ||
− | + | exec [-cl] [-a name] [command [arguments]] | |
+ | If command is specified, it replaces the shell. No new [[process]] is created. The | ||
+ | arguments become the arguments to command. If the -l option is supplied, the shell | ||
+ | places a dash at the beginning of the zeroth argument passed to command. This is | ||
+ | what login(1) does. The -c option causes command to be executed with an empty | ||
+ | environment. If -a is supplied, the shell passes name as the zeroth argument to | ||
+ | the executed command. If command cannot be executed for some reason, a non- | ||
+ | interactive shell exits, unless the execfail shell option is enabled. In that | ||
+ | case, it returns failure. An interactive shell returns failure if the file cannot | ||
+ | be executed. If command is not specified, any redirections take effect in the | ||
+ | current shell, and the return status is 0. If there is a redirection error, the | ||
+ | return status is 1. | ||
+ | exec > you-file.txt | ||
== Related == | == Related == | ||
− | + | * <code>[[exec]]</code> | |
+ | * <code>[[exec -c]]</code> | ||
== See also == | == See also == | ||
* {{Bash}} | * {{Bash}} | ||
+ | |||
+ | [[Category:Bash]] |
Latest revision as of 10:44, 4 April 2023
exec [-cl] [-a name] [command [arguments]] If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the -l option is supplied, the shell places a dash at the beginning of the zeroth argument passed to command. This is what login(1) does. The -c option causes command to be executed with an empty environment. If -a is supplied, the shell passes name as the zeroth argument to the executed command. If command cannot be executed for some reason, a non- interactive shell exits, unless the execfail shell option is enabled. In that case, it returns failure. An interactive shell returns failure if the file cannot be executed. If command is not specified, any redirections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1.
exec > you-file.txt
Related[edit]
See also[edit]
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: