⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sh.1

📁 Unix操作系统minix 2.0源码
💻 1
字号:
.TH SH 1.SH NAMEsh, ., break, case, cd, continue, eval, exec, exit, export, for, if, read, readonly, set, shift, trap, umask, wait, while \- shell.SH SYNOPSIS\fBsh\fR [\fB\-eiknqstvxu\fR] [\fB\-c \fIstr\fR] \fB[\fIfile\fR]\fR.br.de FL.TP\\fB\\$1\\fR\\$2...de EX.TP 20\\fB\\$1\\fR# \\$2...SH OPTIONS.FL "\-c" "Execute the commands in \fIstr\fR".FL "\-e" "Quit on error".FL "\-i" "Interactive mode; ignore QUIT, TERMINATE, INTERRUPT".FL "\-k" "Look for name=value everywhere on command line".FL "\-n" "Do not execute commands".FL "\-q" "Change qflag from sig_ign to sig_del".FL "\-s" "Read commands from standard input".FL "\-t" "Exit after reading and executing one command".FL "\-v" "Echo input lines as they are read".FL "\-x" "Trace".FL "\-u" "Unset variables".SH EXAMPLES.EX "sh script" "Run a shell script".SH DESCRIPTION.PP.I Shis the shell, which forms the user's main interface with the system.On startup, the shell reads /etc/profile and $HOME/.profile, if they exist,and executes any commands they contain.  The Minix shell has most of thefeatures of the V7 (Bourne) shell, including redirection of input and output,pipes, magic characters, background processes, and shell scripts.  A briefsummary follows, but whole books have been written on shell programming alone..LPSome of the more common notations are:.PP.in +2.45i.ta 2i 2.2i.ti -2.2idate	#	Regular command.ti -2.2isort <file	#	Redirect \fIstdin\fR (standard input).ti -2.2isort <file1  >file2	#	Redirect \fIstdin\fR and \fIstdout\fR.ti -2.2icc file.c  2>error	#	Redirect \fIstderr\fR.ti -2.2ia.out >f  2>&1	#	Combine standard output and standard error.ti -2.2isort <file1  >>file2	#	Append output to \fIfile2\fR.ti -2.2isort <file1  >file2 &	#	Background job.ti -2.2i(ls \-l; a.out) &	#	Run two background commands sequentially.ti -2.2isort <file | wc	#	Two-process pipeline.ti -2.2isort <f | uniq | wc	#	Three-process pipeline.ti -2.2ils \-l *.c	#	List all files ending in \fI.c\fR.ti -2.2ils \-l [\fIa-c\fR]*	#	List all files beginning with \fIa\fR, \fIb\fR, or \fIc\fR.ti -2.2ils \-l ?	#	List all one-character file names.ti -2.2ils \e?	#	List the file whose name is question mark.ti -2.2ils \(fm???\(fm	#	List the file whose name is three question marks.ti -2.2iv=/usr/ast	#	Set shell variable \fIv\fR.ti -2.2ils \-l $v	#	Use shell variable \fIv\fR.ti -2.2iPS1=\(fmHi! \(fm	#	Change the primary prompt to \fIHi!\fR.ti -2.2iPS2=\(fmMore: \(fm	#	Change the secondary prompt to \fIMore:\fR.ti -2.2ils \-l $HOME	#	List the home directory.ti -2.2iecho $PATH	#	Echo the search path.ti -2.2iecho $?	#	Echo exit status of previous command in decimal.ti -2.2iecho $$	#	Echo shell's pid in decimal.ti -2.2iecho $!	#	Echo PID of last background process.ti -2.2iecho $#	#	Echo number of parameters (shell script).ti -2.2iecho $2	#	Echo second parameter (shell script).ti -2.2iecho "$2"	#	Echo second parameter without expanding spaces.ti -2.2iecho $*	#	Echo all parameters (shell script).ti -2.2iecho $@	#	Echo all parameters (shell script).ti -2.2iecho "$@"	#	Echo all parameters without expanding spaces.in -2.45i.LPThe shell uses the following variables for specific purposes:.PP.in +2.25i.ta 2i.ti -2iSHELL	the path of the current shell.ti -2iHOME	the default value for the cd(1) command.ti -2iPATH	the directories to be searched to find commands.ti -2iIFS	the internal field separators for command strings.ti -2iPS1	the primary shell prompt.ti -2iPS2	the secondary shell prompt.in -2.25i.LPThere are various forms of substitution on the shell command line:.PP.in +2.25i.ta 2i.ti -2i`...`	Command string between back-quotes is replaced by its output.ti -2i"..."	Permits variable substitution between quotes.ti -2i\&'...'	Inhibits variable substitution between quotes.ti -2i$VAR	Replaced by contents of variable VAR.ti -2i${VAR}	Delimits variable VAR from any following string.in -2.25i.LPThe expressions below depend on whether or not VAR has ever been set.If VAR has been set, they give:.PP.in +2.25i.ta 2i.ti -2i${VAR-str}	Replace expression by VAR, else by str.ti -2i${VAR=str}	Replace expression by VAR, else by str and set VAR to str.ti -2i${VAR?str}	Replace expression by VAR, else print str and exit shell.ti -2i${VAR+str}	Replace expression by str, else by null string.in -2.25i.LPIf a colon is placed after VAR, the expressions depend on whether or notVAR is currently set and non-null..LPThe shell has a number of built-in commands:.PP.in +2.25i.ta 2i.ti -2i:	return true status.ti -2i\&. fn	execute shell script fn on current path.ti -2ibreak [n]	break from a for, until or while loop; exit n levels.ti -2icontinue [n]	continue a for, until or while loop; resume nth loop.ti -2icd [dir]	change current working directory; move to $HOME.ti -2ieval cmd	rescan cmd, performing substitutions.ti -2ieval	rescan the current command line.ti -2iexec cmd	execute cmd without creating a new process.ti -2iexec <|>	with no command name, modify shell I/O.ti -2iexit [n]	exit a shell program, with exit value n.ti -2iexport [var]	export var to shell's children; list exported variables.ti -2ipwd	print the name of the current working directory.ti -2iread var	read a line from stdin and assign to var.ti -2ireadonly [var]	make var readonly; list readonly variables.ti -2iset -f	set shell flag (+f unsets flag).ti -2iset str	set positional parameter to str.ti -2iset	show the current shell variables.ti -2ishift	reassign positional parameters (except ${0}) one left.ti -2itimes	print accumulated user and system times for processes.ti -2itrap arg sigs	trap signals sigs and run arg on receipt.ti -2itrap	list trapped signals.ti -2iumask [n]	set the user file creation mask; show the current umask.ti -2iwait [n]	wait for process pid n; wait for all processes.in -2.25i.LPThe shell also contains a programming language, which has the followingoperators and flow control statements:.PP.in +3.50i.ta 2i 3.25i.ti -3.25i#	Comment	The rest of the line is ignored.ti -3.25i=	Assignment	Set a shell variable.ti -3.25i&&	Logical AND	Execute second command only if first succeeds.ti -3.25i||	Logical OR	Execute second command only if first fails.ti -3.25i(...)	Group	Execute enclosed commands before continuing.in -3.50i.PP.in +2.25i.ta 2i.ti -2ifor	For loop (for ... in ... do ... done).ti -2icase	Case statement ((case ... ) ... ;; ... esac).ti -2iesac	Case statement end.ti -2iwhile	While loop (while ... do ... done).ti -2ido	Do/For/While loop start (do ... until ...).ti -2idone	For/While loop end.ti -2iif	Conditional statement (if ... else ... elif ... fi).ti -2iin	For loop selection.ti -2ithen	Conditional statement start.ti -2ielse	Conditional statement alternative.ti -2ielif	Conditional statement end.ti -2iuntil	Do loop end.ti -2ifi	Conditional statement end.in -2.25i.SH "SEE ALSO".BR echo (1),.BR expr (1),.BR pwd (1),.BR true (1).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -