Home > System Tutorial > LINUX > body text

List all Bash Shell built-in commands

WBOY
Release: 2024-05-09 09:10:24
forward
398 people have browsed it

A shell built-in command is a command or a function that is called from the shell and is executed directly in the shell. The bash shell executes the command directly without calling other programs. You can use the help command to view information about Bash built-in commands. Below are several different types of built-in commands.

Types of built-in commands

The types are as follows:
Bourne Shell built-in commands: Built-in commands are inherited from Bourne Shell.
Bash built-in commands: A list of Bash-specific built-in commands.
Modify Shell Behavior: Built-in commands that modify shell properties and optional behavior.
Special built-in commands: Built-in commands that are specially classified by POSIX.

How to view all bash built-in commands

There are the following commands:

$ help
$ help | less
$ help | grep read
Copy after login

Sample output:

GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
 job_spec [&]                            history [-c] [-d offset] [n] or hist>
 (( expression ))                        if COMMANDS; then COMMANDS; [ elif C>
 . filename [arguments]                  jobs [-lnprs] [jobspec ...] or jobs >
 :                                       kill [-s sigspec | -n signum | -sigs>
 [ arg... ]                              let arg [arg ...]
 [[ expression ]]                        local [option] name[=value] ...
 alias [-p] [name[=value] ... ]          logout [n]
 bg [job_spec ...]                       mapfile [-n count] [-O origin] [-s c>
 bind [-lpvsPVS] [-m keymap] [-f filen>  popd [-n] [+N | -N]
 break [n]                               printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]       pushd [-n] [+N | -N | dir]
 caller [expr]                           pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...)>  read [-ers] [-a array] [-d delim] [->
 cd [-L|-P] [dir]                        readarray [-n count] [-O origin] [-s>
 command [-pVv] command [arg ...]        readonly [-af] [name[=value] ...] or>
 compgen [-abcdefgjksuv] [-o option]  >  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] >  select NAME [in WORDS ... ;] do COMM>
 compopt [-o|+o option] [-DE] [name ..>  set [--abefhkmnptuvxBCHP] [-o option>
 continue [n]                            shift [n]
 coproc [NAME] command [redirections]    shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFilrtux] [-p] [name[=val>  source filename [arguments]
 dirs [-clpv] [+N] [-N]                  suspend [-f]
 disown [-h] [-ar] [jobspec ...]         test [expr]
 echo [-neE] [arg ...]                   time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [na>  times
 eval [arg ...]                          trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [argume>  true
 exit [n]                                type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or ex>  typeset [-aAfFilrtux] [-p] name[=val>
 false                                   ulimit [-SHacdefilmnpqrstuvx] [limit>
 fc [-e ename] [-lnr] [first] [last] o>  umask [-p] [-S] [mode]
 fg [job_spec]                           unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMAND>  unset [-f] [-v] [name ...]
 for (( exp1; exp2; exp3 )); do COMMAN>  until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name >  variables - Names and meanings of so>
 getopts optstring name [arg]            wait [id]
 hash [-lr] [-p pathname] [-dt] [name >  while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]               { COMMANDS ; }
Copy after login

Another option is to use the following command:

compgen -b
compgen -b | more
Copy after login
View Bash’s built-in command information

Run the following to get detailed information:

help command
help read
Copy after login

To get only a list of all built-in commands with short descriptions, execute the following:

$ help -d
Copy after login
Find syntax and other options for built-in commands

Use the following syntax to find out more related built-in commands:

help name 
help cd 
help fg 
help for 
help read 
help :
Copy after login

Sample output:

:: :
 Null command.
 
 No effect; the command does nothing.
 
 Exit Status:
 Always succeeds
Copy after login
Find out whether a command is internal (built-in) or external

Use type command or command command:

type -a command-name-here 
type -a cd 
type -a uname 
type -a : 
type -a ls
Copy after login

or:

type -a cd uname : ls uname
Copy after login

Sample output:

cd is a shell builtin
uname is /bin/uname
: is a shell builtin
ls is aliased to `ls --color=auto'
ls is /bin/ls
l is a function
l ()
{
 ls --color=auto
}
Copy after login

or:

command -V ls 
command -V cd 
command -V foo
Copy after login

列出所有的 Bash Shell 内置命令
Author: Vivek Gite

The above is the detailed content of List all Bash Shell built-in commands. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!