📄 sh.1
字号:
locations of commands.With no arguments whatsoever,the.Ic hashcommand prints out the contents of this table.Entries which have not been looked at since the last.Ic cdcommand are marked with an asterisk; it is possible for these entriesto be invalid..PpWith arguments, the.Ic hashcommand removes the specified commands from the hash table (unlessthey are functions) and then locates them.With the.Fl voption, hash prints the locations of the commands as it finds them.The.Fl roption causes the hash command to delete all the entries in the hash tableexcept for functions..It inputrc Ar fileRead the.Va fileto set keybindings as defined by.Xr editrc 5 ..It jobid Op Ar jobPrint the process id's of the processes in the job.If the.Ar jobargument is omitted, the current job is used..It jobsThis command lists out all the background processeswhich are children of the current shell process..It pwd Op Fl LPPrint the current directory.If .Fl Lis specified the cached value (initially set from.Ev PWD )is checked to see if it refers to the current directory, if it doesthe value is printed.Otherwise the current directory name is found using.Xr getcwd(3) .The environment variable.Ev PWDis set to printed value..PpThe default is.Ic pwd.Fl L ,but note that the builtin.Ic cdcommand doesn't currently support.Fl Lor.Fl Pand will cache (almost) the absolute path.If.Ic cdis changed,.Ic pwdmay be changed to default to.Ic pwd.Fl P ..PpIf the current directory is renamed and replaced by a symlink to thesame directory, or the initial.Ev PWDvalue followed a symbolic link, then the cached value may notbe the absolute path..PpThe builtin command may differ from the program of the same name becausethe program will use.Ev PWDand the builtin uses a separately cached value..It Xo read Op Fl p Ar prompt.Op Fl r.Ar variable.Op Ar ....XcThe prompt is printed if the.Fl poption is specified and the standard input is a terminal.Then a line is read from the standard input.The trailing newline is deleted from theline and the line is split as described in the section on word splittingabove, and the pieces are assigned to the variables in order.If there are more pieces than variables, the remaining pieces(along with the characters in.Ev IFSthat separated them) are assigned to the last variable.If there are more variables than pieces,the remaining variables are assigned the null string.The.Ic readbuiltin will indicate success unless EOF is encountered on input, inwhich case failure is returned..PpBy default, unless the.Fl roption is specified, the backslash.Dq \eacts as an escape character, causing the following character to be treatedliterally.If a backslash is followed by a newline, the backslash and thenewline will be deleted..It readonly Ar name ....It readonly Fl pThe specified names are marked as read only, so that they cannot besubsequently modified or unset.The shell allows the value of a variableto be set at the same time it is marked read only by writing.Pp.Dl readonly name=value.PpWith no arguments the readonly command lists the names of all read onlyvariables.With the.Fl poption specified the output will be formatted suitably for non-interactive use..Pp.It Xo set.Oo {.Fl options | Cm +options | Cm -- }.Oc Ar arg ....XcThe.Ic setcommand performs three different functions..PpWith no arguments, it lists the values of all shell variables..PpIf options are given, it sets the specified optionflags, or clears them as described in the section called.Sx Argument List Processing ..PpThe third use of the set command is to set the values of the shell'spositional parameters to the specified args.To change the positionalparameters without changing any options, use.Dq --as the first argument to set.If no args are present, the set commandwill clear all the positional parameters (equivalent to executing.Dq shift $# . ).It setvar Ar variable Ar valueAssigns value to variable.(In general it is better to writevariable=value rather than using.Ic setvar ..Ic setvaris intended to be used infunctions that assign values to variables whose names are passed asparameters.).It shift Op Ar nShift the positional parameters n times.A.Ic shiftsets the value of.Va $1to the value of.Va $2 ,the value of.Va $2to the value of.Va $3 ,and so on, decreasingthe value of.Va $#by one.If there are zero positional parameters,.Ic shiftdoes nothing..It Xo trap.Op Fl l.Xc.It Xo trap.Op Ar action.Ar signal ....XcCause the shell to parse and execute action when any of the specifiedsignals are received.The signals are specified by signal number or as the name of the signal.If.Ar signalis.Li 0 ,the action is executed when the shell exits..Ar actionmay be null, which cause the specified signals to be ignored.With.Ar actionomitted or set to `-' the specified signals are set to their default action.When the shell forks off a subshell, it resets trapped (but not ignored)signals to the default action.The.Ic trapcommand has no effect on signals that wereignored on entry to the shell.Issuing.Ic trapwith option.Ar -lwill print a list of valid signal names..Ic trapwithout any arguments cause it to write a list of signals and theirassociated action to the standard output in a format that is suitableas an input to the shell that achieves the same trapping results..PpExamples:.Pp.Dl trap.PpList trapped signals and their corresponding action.Pp.Dl trap -l.PpPrint a list of valid signals.Pp.Dl trap '' INT QUIT tstp 30.PpIgnore signals INT QUIT TSTP USR1.Pp.Dl trap date INT.PpPrint date upon receiving signal INT.It type Op Ar name ...Interpret each name as a command and print the resolution of the commandsearch.Possible resolutions are:shell keyword, alias, shell builtin,command, tracked alias and not found.For aliases the alias expansion isprinted; for commands and tracked aliases the complete pathname of thecommand is printed..It ulimit Xo.Op Fl H \*(Ba Fl S.Op Fl a \*(Ba Fl tfdscmlpn Op Ar value.XcInquire about or set the hard or soft limits on processes or set newlimits.The choice between hard limit (which no process is allowed toviolate, and which may not be raised once it has been lowered) and softlimit (which causes processes to be signaled but not necessarily killed,and which may be raised) is made with these flags:.Bl -tag -width Fl.It Fl Hset or inquire about hard limits.It Fl Sset or inquire about soft limits.If neither.Fl Hnor.Fl Sis specified, the soft limit is displayed or both limits are set.If both are specified, the last one wins..El.Pp.Bl -tag -width FlThe limit to be interrogated or set, then, is chosen by specifyingany one of these flags:.It Fl ashow all the current limits.It Fl bshow or set the limit on the socket buffer size of a process (in bytes).It Fl tshow or set the limit on CPU time (in seconds).It Fl fshow or set the limit on the largest file that can be created(in 512-byte blocks).It Fl dshow or set the limit on the data segment size of a process (in kilobytes).It Fl sshow or set the limit on the stack size of a process (in kilobytes).It Fl cshow or set the limit on the largest core dump size that can be produced(in 512-byte blocks).It Fl mshow or set the limit on the total physical memory that can bein use by a process (in kilobytes).It Fl lshow or set the limit on how much memory a process can lock with.Xr mlock 2(in kilobytes).It Fl pshow or set the limit on the number of processes this user canhave at one time.It Fl nshow or set the limit on the number of files a process can have open at once.El.PpIf none of these is specified, it is the limit on file size that is shownor set.If value is specified, the limit is set to that number; otherwisethe current limit is displayed..PpLimits of an arbitrary process can be displayed or set using the.Xr sysctl 8utility..Pp.It umask Op Ar maskSet the value of umask (see.Xr umask 2 )to the specified octal value.If the argument is omitted, the umask value is printed..It unalias Xo.Op Fl a.Op Ar name.XcIf.Ar nameis specified, the shell removes that alias.If.Fl ais specified, all aliases are removed..It unset Ar name ...The specified variables and functions are unset and unexported.If a given name corresponds to both a variable and a function, boththe variable and the function are unset..It wait Op Ar jobWait for the specified job to complete and return the exit status of thelast process in the job.If the argument is omitted, wait for all jobs tocomplete and then return an exit status of zero..El.Ss Command Line EditingWhen.Nmis being used interactively from a terminal, the current commandand the command history (see.Ic fcin.Sx Builtins )can be edited using emacs-mode or vi-mode command-line editing.The command.Ql set -o emacsenables emacs-mode editing.The command.Ql set -o vienables vi-mode editing and places sh into vi insert mode.(See the.Sx Argument List Processingsection above.).PpThe vi mode uses commands similar to a subset of those described in the.Xr vi 1man page.With vi-modeenabled, sh can be switched between insert mode and command mode.It's similar to vi: typing.Aq ESCwill throw you into command VI command mode.Hitting.Aq returnwhile in command mode will pass the line to the shell..PpThe emacs mode uses commands similar to a subset available inthe emacs editor.With emacs-mode enabled, special keys can be used to modify the textin the buffer using the control key..Pp.Nmuses the.Xr editline 3library..Sh EXIT STATUSErrors that are detected by the shell, such as a syntax error, will cause theshell to exit with a non-zero exit status.If the shell is not aninteractive shell, the execution of the shell file will be aborted.Otherwisethe shell will return the exit status of the last command executed, orif the exit builtin is used with a numeric argument, it will return theargument..Sh ENVIRONMENT.Bl -tag -width MAILCHECK.It Ev HOMESet automatically by.Xr login 1from the user's login directory in the password file.Pq Xr passwd 5 .This environment variable also functions as the default argument for thecd builtin..It Ev PATHThe default search path for executables.See the above section.Sx Path Search ..It Ev CDPATHThe search path used with the cd builtin..It Ev LANGThe string used to specify localization information that allows usersto work with different culture-specific and language conventions.See.Xr nls 7 ..It Ev MAILThe name of a mail file, that will be checked for the arrival of new mail.Overridden by.Ev MAILPATH ..It Ev MAILCHECKThe frequency in seconds that the shell checks for the arrival of mailin the files specified by the.Ev MAILPATHor the.Ev MAILfile.If set to 0, the check will occur at each prompt..It Ev MAILPATHA colon.Dq \&:separated list of file names, for the shell to check for incoming mail.This environment setting overrides the.Ev MAILsetting.There is a maximum of 10 mailboxes that can be monitored at once..It Ev PS1The primary prompt string, which defaults to.Dq $ \ ,unless you are the superuser, in which case it defaults to.Dq # \ ..It Ev PS2The secondary prompt string, which defaults to.Dq \*[Gt] \ ..It Ev PS4Output before each line when execution trace (set -x) is enabled,defaults to.Dq + \ ..It Ev IFSInput Field Separators.This is normally set to.Aq space ,.Aq tab ,and.Aq newline .See the.Sx White Space Splittingsection for more details..It Ev TERMThe default terminal setting for the shell.This is inherited bychildren of the shell, and is used in the history editing modes..It Ev HISTSIZEThe number of lines in the history buffer for the shell..El.Sh FILES.Bl -item -width HOMEprofilexxxx.It.Pa $HOME/.profile.It.Pa /etc/profile.El.Sh SEE ALSO.Xr csh 1 ,.Xr echo 1 ,.Xr getopt 1 ,.Xr ksh 1 ,.Xr login 1 ,.Xr printf 1 ,.Xr test 1 ,.Xr editline 3 ,.Xr getopt 3 ,.\" .Xr profile 4 ,.Xr editrc 5 ,.Xr passwd 5 ,.Xr environ 7 ,.Xr nls 7 ,.Xr sysctl 8.Sh HISTORYA.Nmcommand appeared in.At v1 .It was, however, unmaintainable so we wrote this one..Sh BUGSSetuid shell scripts should be avoided at all costs, as they are asignificant security risk..PpPS1, PS2, and PS4 should be subject to parameter expansion beforebeing displayed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -