-->
Previous Table of Contents Next


The bash Shell help Facility

When you type a command at the prompt, the shell program takes what you’ve written, interprets it as necessary, and passes the result to the Linux operating system. Linux then performs the actions requested of it. Many Linux commands require Linux to find and start up a new program. However, the shell itself can perform a number of functions. These functions can be simple, often-used commands, so that the overhead of starting up separate programs is eliminated or they can be facilities that make the shell environment friendlier and more useful. One of these facilities is the help command, which provides information on the built-in functions of the bash shell.

Type help at the prompt. You will see at least some of the following:


GNU bash, version 1.14.15(1)

Shell commands that 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.



A star (*) next to a name means that the command is disabled.

 %[DIGITS | WORD] [&]                    . [filename]

 :                                       [ arg… ]

 alias [ name[=value] … ]   bg      [job_spec]

 bind [-lvd] [-m keymap] [-f filena      break [n]

 builtin [shell-builtin [arg …] ]   case WORD in [PATTERN [| PATTERN].

 cd [dir]                                command [-pVv] [command [arg …]]

 continue [n]                            declare [-[frxi]] name[=value] …

 dirs [-l]                               echo [-neE] [arg …]

 enable [-n] [name …]               eval [arg …]

 exec [ [-] file [redirection …]]   exit [n]

 export [-n] [-f] [name …] or exp   fc [-e name] [-nlr] [first] [last

 fg [job_spec]                           for NAME [in WORDS … ;] do COMMA

 function NAME { COMMANDS ; }  or NA getopts optstring name [arg]

 hash [-r] [name …]                 help [pattern …]

 history [n] [ [-awrn] [filename]]       if COMMANDS; then COMMANDS; [elif

 jobs [-lnp] [jobspec …] | jobs -   kill [-s sigspec | -sigspec] [pid

 let arg [arg …]                    local name[=value] …

 logout                                  popd [+n | -n]

 pushd [dir | +n | -n]               pwd

 read [-r] [name …]                 readonly [-n] [-f] [name …] or r

 return [n]                              select NAME [in WORDS … ;] do CO

 set [--abefhknotuvxldHCP] [-o opti      shift [n]

 source filename                         suspend [-f]

 test [expr]                             times

 trap [arg] [signal_spec]                type [-all] [-type | -path] [name

 typeset [-[frxi]] name[=value] …   ulimit [-SHacdmstfpnuv [limit]]

 umask [-S] [mode]                       unalias [-a] [name …]

 unset [-f] [-v] [name …]           until COMMANDS; do COMMANDS; done

 variables - Some variable names an wait [n]

 while COMMANDS; do COMMANDS; done { COMMANDS }

You will have to pipe the output of help to more (help | more) to keep the first part from scrolling off your screen.

Wildcards: * and ?

In many a late-night card game, jokers are shuffled into the deck. The jokers are wildcards that can become any card of your choice. This is obviously very useful! Linux also has wildcards. They are more useful than jokers in a card game.

Linux has several wildcards. Wildcards are used as a convenient and powerful shortcut when specifying files (or directories) that a command is to operate on. We will briefly look at the two most popular wildcards: * and ?. (There are quite a few more wildcards supported by Linux, but they are seldom used and would only complicate the issue at this point.)

The most commonly used wildcard is *, which stands in for any combination of one or more characters. For example, c* matches all filenames that begin with c. You can see this for yourself by typing ls /bin/c*. What happens if you type ls /bin/c*t at the command line? How about ls /bin/*t at the command line?

The ? wildcard is more restrictive than *. It stands in only for any one character. You can see this by comparing ls/bin/d* with ls/bin/d?.


Note:  
Wildcards can only be used to match filenames and directory names. You can’t, for example, type pass* at the Linux prompt and expect Linux to run the passwd program for you.


Warning:  
Be very careful when using wildcards with dangerous commands, such as the ones used to permanently delete files! A good check is to run ls with the wildcards you plan to use and examine the resulting list of files to see whether the wildcard combination did what you expected it to do. Also double-check that you typed everything correctly before pressing the Enter key!


Previous Table of Contents Next