TrumanWong

builtin

Execute bash built-in commands.

Summary

builtin [shell-builtin [arg ...]]

The main purpose

  • Used to execute specified bash built-in commands.
  • The bash built-in commands called by the builtin command take precedence over external commands with the same name and shell functions with the same name.

Parameters

shell-builtin (optional): The bash built-in command to be called.

arg (optional): One or more arguments passed to the bash built-in command.

return value

Returns the return value from execution of this builtin command, unless no bash builtin command is passed or the builtin command is disabled.

example

Priority order for cases with the same name:

builtin built-in commands > functions > built-in commands > external commands

# For the situation where the external command has the highest priority, please refer to the enable command.
# At this time, the built-in commands will be used first.
echo "the Great Wall"
# Call the built-in command type and return the command type (builtin)
type -t echo
#Define echo function
echo(){
     printf "123\n"
}
# At this time, the function with the same name is used first, and (123) is displayed.
echo
# Call the built-in command type and return the command type (function)
type -t echo
# At this time, the built-in commands will be used first.
builtin echo -e "backslash \\"
# Execute shell internal instructions and output the command alias under the current system
builtin alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

Notice

  1. This command is a built-in bash command. For related help information, please see the help command.

  2. If the built-in command to be called is disabled (including builtin), the execution will report an error; please refer to the enable command for disabling and enabling built-in commands.