- 论坛徽章:
- 0
|
Bash Keywords
A keyword is a word or symbol that has a special meaning to a computer language.The
following symbols and words have special meanings to Bash when they are unquoted
and the first word of a command.
! esac select }
case fi then [[
do for until ]]
done function while
elif if time
else in {
Built-In Commands
alias—Manages aliases.
bg—Starts a suspended task in the background.
bind—Manages keyboard mappings.
builtin—Runs a built-in shell command.
cd—Changes the directory.
command—Runs a Linux command.
declare—Declares variables.
dirs—Displays cd directory stack.
disown—Stops monitoring a background job.
echo—Prints to standard output.
enable—Turns the built-in shell commands on or off.
eval—Runs a command after performing shell substitutions/expansions.
exec—Leaves the shell and switches to a new program.
exit—Exits Bash and returns a status code.
export—Manages exported variables.
false—Returns a non-zero status code.
fc—Finds and edits command history lines.
fg—Runs a suspended job in the foreground.
function—Declares a function.
hash—Manages a Bash command table.
history—Manages the command history.
jobs—Manages your background jobs.
let—Evaluates expressions.
local—Declares a local function variable.
logout—Exits the shell when in interactive mode.
popd—Discards a cd directory stack entry.
printf—Prints with formatting to standard output.
pushd—Adds a change directory stack entry.
pwd—Shows the current directory’s pathname.
read—Reads from standard input or a file.
readonly—Manages read-only variables.
return—Returns from a function.
set—Turns a Bash option on or off, or assigns new parameter values.
shift—Shifts the parameters.
shopt—Shows or changes shell options.
source—Runs another script and returns.
suspend—Puts a script to sleep until a signal is received.
test—Evaluates an expression.
time—Shows execution statistics for a command.
times—Shows the accumulated execution statistics for the shell.
trap—Manages signal handlers or catch signals.
true—Returns a success status code (that is, 0).
type—Determines the type of command (that is, whether it’s built in or an external
command).
typeset—(obsolete) Declares variables.
ulimit—Manages the user’s resources.
umask—Manages the default file-creation permissions.
unalias—Discards an alias.
unset—Discards a variable.
Bash Options(shopt command)
Option Default Description
-o allexport Off All variables that are modified or created are exported.
-o braceexapnd On The shell performs curly brace expansion.
cdable_vars Off The built-in cd command assumes that unrecognized
directories are variables containing a directory path.
cdspell Off Spell-checks the directory component in a cd path.
checkhash Off Verifies that commands in the command lookup table
still exist before trying a path search for the command
to run.
checkwinsize Off Determines whether the display window has been
resized after every command.
cmdhist On Allows multiple line history command editing.
dotglob Off Allows . files in a pathname expansion.
-o emacs Off Use emacs-style line-editing keys.
-o errexit Off Exits immediately if a command exits with a non-zero
status.
execfail Off Script fails when built-in exec command can’t execute
a command.
expand_aliases On Allows aliases.
extglob Off Enables extended pattern-matching features for file-
names.
-o hashall On Remembers the location of commands as they are
looked up.
histappend Off Command history appends the history file instead of
overwriting it.
histreedit Off Enables user to edit failed history substitutions.
-o histexpand On Enables ! style history substitution.
-o history on Enables command history.
histverify Off History substitutions can be further edited.
hostcomplete On Completes hostnames containing an @.
huponexit Off Sends a hang-up signal to all jobs still running when
this script exits.
-o ignoreeof Off Ensures that an interactive shell will not exit upon
reading end-of-file.
interactive - On Allows comments to appear in interactive commands.
comments
-o keyword Off All assignment arguments are placed in the environ-
ment for a command, not just those that precede the
command name.
lithist Off A line with multiple commands is split up and stored
as separate commands in the command history.
mailwarn Off Informs the user when new mail arrives when at the
shell prompt.
-o monitor On Enables job control.
no_empty_cmd_ Off Doesn’t allow command completion on an empty line.
completion
nocaseglob Off Ignores case when pattern-matching pathnames.
-o noclobber Off If set, does not allow existing regular files to be
overwritten by redirection of output.
-o noexec Off Reads commands but does not execute them.
-o noglob Off Disables filename generation (globbing).
-o notify Off Notifies users of job termination immediately.
-o nounset Off Treats unset variables as errors when substituting.
nullglob Off Patterns that do not match anything return an empty
string instead of themselves.
-o onecmd Off Exits after reading and executing one command.
-o physical Off If set, does not follow symbolic links when executing
commands, such as cd, that change the current
directory.
-o posix Off Conforms to the POSIX 1003.2 standard.
-o privileged Off Turned on whenever the real and effective user IDs
do not match. Disables processing of the $ENV file and
-o importing of shell functions.Turning this option off
causes the effective uid and gid to be set to the real
uid and gid.
progcomp On Enables programmable completion.
promptvars On Process prompts strings for variables and parameters.
restricted_shell - On i f the shell is a restricted shell.This option is
read-only.
shift_verbose Off Returns an error when no parameters are left to shift.
sourcepath On Finds scripts for . or source commands using the
PATH variable.
-o verbose Off Prints shell input lines as they are read.
-o vi Off Uses vi-style line-editing keys.
xpg_echo Off Built-in command echo processes escape sequences
by default.
-o xtrace Off Prints commands and their arguments as they are
executed.
to be continued......
from Ken O Burtch << Linux Shell Scripting with Bash>>
[ 本帖最后由 BLZer 于 2007-12-3 17:47 编辑 ] |
|