?? 01. unix note.txt
字號(hào):
made to turn off readonly status for a readonly variable, an attempt is made to turn
off array status for an array variable, or an attempt is made to display a non-exis-
tent function with -f.
dirs [-clpv] [+n] [-n]
Without options, displays the list of currently remembered directories. The default
display is on a single line with directory names separated by spaces. Directories
are added to the list with the pushd command; the popd command removes entries from
the list.
+n Displays the nth entry counting from the left of the list shown by dirs when
invoked without options, starting with zero.
-n Displays the nth entry counting from the right of the list shown by dirs when
invoked without options, starting with zero.
-c Clears the directory stack by deleting all of the entries.
-l Produces a longer listing; the default listing format uses a tilde to denote
the home directory.
-p Print the directory stack with one entry per line.
-v Print the directory stack with one entry per line, prefixing each entry with
its index in the stack.
The return value is 0 unless an invalid option is supplied or n indexes beyond the
end of the directory stack.
disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of active jobs. If the -h
option is given, each jobspec is not removed from the table, but is marked so that
SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is
present, and neither the -a nor the -r option is supplied, the current job is used.
If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r
option without a jobspec argument restricts operation to running jobs. The return
value is 0 unless a jobspec does not specify a valid job.
echo [-neE] [arg ...]
Output the args, separated by spaces, followed by a newline. The return status is
always 0. If -n is specified, the trailing newline is suppressed. If the -e option
is given, interpretation of the following backslash-escaped characters is enabled.
The -E option disables the interpretation of these escape characters, even on systems
where they are interpreted by default. The xpg_echo shell option may be used to
dynamically determine whether or not echo expands these escape characters by default.
echo does not interpret -- to mean the end of options. echo interprets the following
escape sequences:
\a alert (bell)
\b backspace
\c suppress trailing newline
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\0nnn the eight-bit character whose value is the octal value nnn (zero to three
octal digits)
\nnn the eight-bit character whose value is the octal value nnn (one to three octal
digits)
\xHH the eight-bit character whose value is the hexadecimal value HH (one or two
hex digits)
enable [-adnps] [-f filename] [name ...]
Enable and disable builtin shell commands. Disabling a builtin allows a disk command
which has the same name as a shell builtin to be executed without specifying a full
pathname, even though the shell normally searches for builtins before disk commands.
If -n is used, each name is disabled; otherwise, names are enabled. For example, to
use the test binary found via the PATH instead of the shell builtin version, run
‘‘enable -n test’’. The -f option means to load the new builtin command name from
shared object filename, on systems that support dynamic loading. The -d option will
delete a builtin previously loaded with -f. If no name arguments are given, or if
the -p option is supplied, a list of shell builtins is printed. With no other option
arguments, the list consists of all enabled shell builtins. If -n is supplied, only
disabled builtins are printed. If -a is supplied, the list printed includes all
builtins, with an indication of whether or not each is enabled. If -s is supplied,
the output is restricted to the POSIX special builtins. The return value is 0 unless
a name is not a shell builtin or there is an error loading a new builtin from a
shared object.
eval [arg ...]
The args are read and concatenated together into a single command. This command is
then read and executed by the shell, and its exit status is returned as the value of
eval. If there are no args, or only null arguments, eval returns 0.
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 arg passed to command. This is what
login(1) does. The -c option causes command to be executed with an empty environ-
ment. If -a is supplied, the shell passes name as the zeroth argument to the exe-
cuted command. If command cannot be executed for some reason, a non-interactive
shell exits, unless the shell option execfail is enabled, in which 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.
exit [n]
Cause the shell to exit with a status of n. If n is omitted, the exit status is that
of the last command executed. A trap on EXIT is executed before the shell termi-
nates.
export [-fn] [name[=word]] ...
export -p
The supplied names are marked for automatic export to the environment of subsequently
executed commands. If the -f option is given, the names refer to functions. If no
names are given, or if the -p option is supplied, a list of all names that are
exported in this shell is printed. The -n option causes the export property to be
removed from each name. If a variable name is followed by =word, the value of the
variable is set to word. export returns an exit status of 0 unless an invalid option
is encountered, one of the names is not a valid shell variable name, or -f is sup-
plied with a name that is not a function.
fc [-e ename] [-nlr] [first] [last]
fc -s [pat=rep] [cmd]
Fix Command. In the first form, a range of commands from first to last is selected
from the history list. First and last may be specified as a string (to locate the
last command beginning with that string) or as a number (an index into the history
list, where a negative number is used as an offset from the current command number).
If last is not specified it is set to the current command for listing (so that ‘‘fc
-l -10’’ prints the last 10 commands) and to first otherwise. If first is not speci-
fied it is set to the previous command for editing and -16 for listing.
The -n option suppresses the command numbers when listing. The -r option reverses
the order of the commands. If the -l option is given, the commands are listed on
standard output. Otherwise, the editor given by ename is invoked on a file contain-
ing those commands. If ename is not given, the value of the FCEDIT variable is used,
and the value of EDITOR if FCEDIT is not set. If neither variable is set, is used.
When editing is complete, the edited commands are echoed and executed.
In the second form, command is re-executed after each instance of pat is replaced by
rep. A useful alias to use with this is ‘‘r="fc -s"’’, so that typing ‘‘r cc’’ runs
the last command beginning with ‘‘cc’’ and typing ‘‘r’’ re-executes the last command.
If the first form is used, the return value is 0 unless an invalid option is encoun-
tered or first or last specify history lines out of range. If the -e option is sup-
plied, the return value is the value of the last command executed or failure if an
error occurs with the temporary file of commands. If the second form is used, the
return status is that of the command re-executed, unless cmd does not specify a valid
history line, in which case fc returns failure.
fg [jobspec]
Resume jobspec in the foreground, and make it the current job. If jobspec is not
present, the shell’s notion of the current job is used. The return value is that of
the command placed into the foreground, or failure if run when job control is dis-
abled or, when run with job control enabled, if jobspec does not specify a valid job
or jobspec specifies a job that was started without job control.
getopts optstring name [args]
getopts is used by shell procedures to parse positional parameters. optstring con-
tains the option characters to be recognized; if a character is followed by a colon,
the option is expected to have an argument, which should be separated from it by
white space. The colon and question mark characters may not be used as option char-
acters. Each time it is invoked, getopts places the next option in the shell vari-
able name, initializing name if it does not exist, and the index of the next argument
to be processed into the variable OPTIND. OPTIND is initialized to 1 each time the
shell or a shell script is invoked. When an option requires an argument, getopts
places that argument into the variable OPTARG. The shell does not reset OPTIND auto-
matically; it must be manually reset between multiple calls to getopts within the
same shell invocation if a new set of parameters is to be used.
When the end of options is encountered, getopts exits with a return value greater
than zero. OPTIND is set to the index of the first non-option argument, and name is
set to ?.
getopts normally parses the positional parameters, but if more arguments are given in
args, getopts parses those instead.
getopts can report errors in two ways. If the first character of optstring is a
colon, silent error reporting is used. In normal operation diagnostic messages are
printed when invalid options or missing option arguments are encountered. If the
variable OPTERR is set to 0, no error messages will be displayed, even if the first
character of optstring is not a colon.
If an invalid option is seen, getopts places ? into name and, if not silent, prints
an error message and unsets OPTARG. If getopts is silent, the option character found
is placed in OPTARG and no diagnostic message is printed.
If a required argument is not found, and getopts is not silent, a question mark (?)
is placed in name, OPTARG is unset, and a diagnostic message is printed. If getopts
is silent, then a colon (:) is placed in name and OPTARG is set to the option charac-
ter found.
getopts returns true if an option, specified or unspecified, is found. It returns
false if the end of options is encountered or an error occurs.
hash [-lr] [-p filename] [-dt] [name]
For each name, the full file name of the command is determined by searching the
directories in $PATH and remembered. If the -p option is supplied, no path search is
performed, and filename is used as the full file name of the command. The -r option
causes the shell to forget all remembered locations. The -d option causes the shell
to forget the remembered location of each name. If the -t option is supplied, the
full pathname to which each name corresponds is printed. If multiple name arguments
are supplied with -t, the name is printed before the hashed full pathname. The -l
option causes output to be displayed in a format that may be reused as input. If no
arguments are given, or if only -l is supplied, information about remembered commands
is printed. The return status is true unless a name is not found or an invalid
option is supplied.
help [-s] [pattern]
Display helpful information about builtin commands. If pattern is specified, help
gives detailed help on all commands matching pattern; otherwise help for all the
builtins and shell control structures is printed. The -s option restricts the infor-
mation displayed to a short usage synopsis. The return status is 0 unless no command
matches pattern.
history [n]
history -c
history -d offset
history -anrw [filename]
history -p arg [arg ...]
history -s arg [arg ...]
With no options, display the command history list with line numbers. Lines listed
with a * have been modified. An argument of n lists only the last n lines. If the
shell variable HISTTIMEFORMAT is set and not null, it is used as a format string for
strftime(3) to display the time stamp associated with each displayed history entry.
No intervening blank is printed between the formatted time stamp and the history
line. If filename is supplied, it is used as the name of the history file; if not,
the value of HISTFILE is used. Options, if supplied, have the following meanings:
-c Clear the history list by deleting all the entries.
-d offset
Delete the history entry at position offset.
-a Append the ‘‘new’’ history lines (history lines entered since the beginning of
the current bash session) to the history file.
-n Read the history lines not already read from the history file into the current
history list. These are lines appended to the history file since the begin-
ning of the current bash session.
-r Read the contents of the history file and use them as the current history.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -