📄 article.ps
字号:
(While the GNU operating system will most lik)97 325.8 R .697(ely include a v)-.1 F .697(ersion of the Berk)-.15 F(ele)-.1 E 3.197(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 337.8 R.015(ault shell.)-.1 F(Lik)5.015 E 2.515(eo)-.1 G .015(ther GNU softw)-2.515 F .016(are, Bash is quite portable.)-.1 F .016(It currently runs on nearly e)5.016 F -.15(ve)-.25 G(ry).15 E -.15(ve)72 349.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F3.023(wo)-.25 G .523(ther operating systems \255 an independently-supported port e)-3.023 F.523(xists for OS/2, and)-.15 F .706(there are rumors of ports to DOS and W)72 361.8 R(indo)-.4 E .706(ws NT)-.25 F 5.706(.P)-.74 G .706(orts to)-5.706 F F5(UNIX)3.206 E F3(-lik)A 3.206(es)-.1 G .706(ystems such as QNX and Minix)-3.206 F(are part of the distrib)72 373.8 Q(ution.)-.2 E .405(The original author of Bash w)97 389.4 R .405(as Brian F)-.1 F .405(ox, an emplo)-.15 F .405(yee of the Free Softw)-.1 F .405(are F)-.1 F2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 401.4 Q -.15(ve)-.25 G(loper and maintainer is Chet Rame).15 E 1.3 -.65(y, a v)-.15H(olunteer who w).45 E(orks at Case W)-.1 E(estern Reserv)-.8 E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(.)-.65 E F2 2.5(2. What')72425.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 441 Q F3 .343(is a name originally coined by Richard Stallman for a f)2.843 F .343(amily of open system standards based)-.1 F(on)72 453 Q F5(UNIX)3.24 EF3 5.74(.T)C .74(here are a number of aspects of)-5.74 F F5(UNIX)3.24 EF3 .74(under consideration for standardization, from the basic)3.24 F.192(system services at the system call and C library le)72 465 R -.15(ve)-.25 G 2.692(lt).15 G 2.692(oa)-2.692 G .192(pplications and tools to system administration and)-2.692 F 2.5(management. Each)72 477 R(area of standardization is assigned to a w)2.5 E(orking group in the 1003 series.)-.1 E 2.814(The POSIX Shell and Utilities standard has been de)97 492.6 R -.15(ve)-.25 G 2.814(loped by IEEE W).15 F 2.813(orking Group 1003.2)-.8 F .254(\(POSIX.2\).\210 It concentrates on the command interpreter interf)72504.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G(cuted).15 E 1.112(from the command line or by other programs.)72 516.6R 1.112(An initial v)6.112 F 1.113(ersion of the standard has been appro)-.15 F -.15(ve)-.15 G 3.613(da).15 G(nd)-3.613 E .365(published by the IEEE, and w)72 528.6 R .365(ork is currently underw)-.1 F .365(ay to update it.)-.1 F .365(There are four primary areas of w)5.365 F(ork)-.1 E(in the 1003.2 standard:)72 540.6 Q 21.5<8341>72 556.2 S .835(spects of the shell')-21.5 F 3.335(ss)-.55 G .835(yntax and command language.)-3.335 F 3.335(An)5.835 G .835(umber of special b)-3.335 F .835(uiltins such as)-.2 F F2(cd)3.335 E F3(and)3.335 E F2(exec)97 568.2 Q F3 .545(are being speci\214ed as part o\f the shell, since their functionality usually cannot be implemented)3.046 F(by a separate e)97 580.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5<8341>72 595.8 S .926(set of utilities to be called by shell scripts and applications.)-18.074 F .927(Examples are programs lik)5.927 F(e)-.1 E F1 .927(sed, tr)3.427 F(,)-1.11 E F3(and)97 607.8 Q F1(awk.)2.797 E F3 .297(Utilities commonly implemented as shell b)5.297 F .296(uiltins are described in this section, such as)-.2 F F2(test)2.796 E F3(and)97 619.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922(xpansion of this section')-3.572 F 3.423(ss)-.55 G .923(cope, termed the User Portability Extension, or UPE, has)-3.423 F(standardized interacti)97 631.8 Q .3 -.15(ve p)-.25 H(rograms such as).15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 647.4 S.288(group of functional interf)-18.712 F .287(aces to services pro)-.1F .287(vided by the shell, such as the traditional)-.15 F/F6 10/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 659.4 S .789(ibrary function.)-3.289 F .789(There are functions to perform shell w)5.789 F .789(ord e)-.1 F .79(xpansions, perform \214lename e)-.15 F(xpan-)-.15 E .324(sion \()97 671.4 R F1(globbing)A F3 .324(\), obtain v)B .323(alues of POSIX.2 system con\214guration v)-.25 F.323(ariables, retrie)-.25 F .623 -.15(ve v)-.25 H .323(alues of en)-.1F(viron-)-.4 E(ment v)97 683.4 Q(ariables \()-.25 E F6(getenv\(\))A F3(\), and other services;).833 E .32 LW 144 691.4 72 691.4 DL F4(*An earlier v)72 703.2 Q(ersion of this article appeared in The Linux Journal.)-.12 E(\210IEEE,)72 715 Q/F7 8/Times-Italic@0 SF 1.231(IEEE Standar)3.231 F 3.231(df)-.296 G 1.231(or Information T)-3.231 F(ec)-.736 E(hnolo)-.12 E 1.231(gy -- P)-.08 F 1.231(ortable Oper)-.64 F 1.232(ating System Interface \(POSIX\) P)-.12 F 1.232(art 2:)-.64 F(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E EP%%Page: 2 2%%BeginPageSetupBP%%EndPageSetup/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q 21.5<8341>72 84 S(suite of \231de)-19 E -.15(ve)-.25 G(lopment\232 utilities such as).15E/F1 10/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)-.15 E F1(cc)2.5 E F0(\), and)A F1(yacc.)2.5 E F0 .483(Bash is concerned with the aspects of the shell')97 99.6 R 2.983(sb)-.55 G(eha)-2.983 E .484(vior de\214ned by POSIX.2.)-.2 F .484(The shell command)5.484 F 1.439(language has of course been standardized, including the basic \215o)72111.6 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15G 1.438(cution con-).15 F 1.284(structs, I/O redirection and pipelining, ar)72 123.6 R 1.284(gument handling, v)-.18 F 1.284(ariable e)-.25 F 1.284(xpansion, and quoting.)-.15 F(The)6.285 E F1(special)3.785 E F0 -.2(bu)72 135.6 S .676(iltins, which must be implemented as part of the shell to pro).2 F .676(vide the desired functionality)-.15 F 3.176(,a)-.65 G .676(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 147.6 R .7(xamples of these are)-.15 F/F2 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201H(l).15 E F0(and)3.201 E F2(export)3.201 E F0 5.701(.O)C .701(ther utilities appear in the sections of)-5.701 F .256(POSIX.2 not de)72 159.6 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\ in some cases must be\) implemented as b).2 F(uiltin)-.2 E .213(commands, such as)72 171.6 R F2 -.18(re)2.713 G(ad).18 E F0(and)2.713 EF2(test)2.713 E F0 5.213(.P)C .213(OSIX.2 also speci\214es aspects of the shell')-5.213 F 2.713(si)-.55 G(nteracti)-2.713 E .513 -.15(ve b)-.25 H(eha).15 E .214(vior as part)-.2F .598(of the UPE, including job control and command line editing.)72183.6 R .598(Interestingly enough, only)5.598 F F1(vi)3.098 E F0 .598(-style line edit-)B(ing commands ha)72 195.6 Q .3 -.15(ve b)-.2 H(een standardized;).15 E F1(emacs)2.5 E F0(editing commands were left out due to objections.)2.5 E 1.128(While POSIX.2 includes much of what the shell has traditionally pro)97211.2 R 1.129(vided, some important things)-.15 F(ha)72 223.2 Q .344-.15(ve b)-.2 H .044(een omitted as being \231be).15 F .044(yond its scope.)-.15 F 5.043<9a54>-.7 G .043(here is, for instance, no mention of a dif)-5.043 F .043(ference between a)-.25 F F1(lo)72 235.2 Q(gin)-.1 E F0 1.445(shell and an)3.945 F 3.945(yo)-.15 G 1.445(ther interacti)-3.945 F1.745 -.15(ve s)-.25 H 1.446(hell \(since POSIX.2 does not specify a login program\).).15 F 1.446(No \214x)6.446 F(ed)-.15 E(startup \214les are de\214ned, either \255 \the standard does not mention)72 247.2 Q F1(.pr)2.5 E(o\214le)-.45 E F0(.)A F2 2.5(3. Basic)72 271.2 R(Bash featur)2.5 E(es)-.18 E F0 1.448(Since the Bourne shell pro)97 286.8 R 1.448(vides Bash with most of its philosophical underpinnings, Bash inherits)-.15 F .64(most of its features and functionality from sh.)72 298.8 R.641(Bash implements all of the traditional sh \215o)5.641 F 3.141(wc)-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 310.8 R F1(for)A F0(,)A F1(if)3.3 E F0(,)A F1(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F.799(of the Bourne shell b)3.3 F .799(uiltins, including those not speci\214ed in the POSIX.2)-.2 F .536(standard, appear in Bash.)72 322.8 R(Shell)5.536 E F1(functions)3.036 EF0 3.036(,i)C .536(ntroduced in the SVR2 v)-3.036 F .537(ersion of the Bourne shell, are similar)-.15 F .779(to shell scripts, b)72 334.8 R .779(ut are de\214ned using a special syntax and are e)-.2 F -.15(xe)-.15 G.779(cuted in the same process as the calling).15 F 2.841(shell. Bash)72346.8 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H2.841(naf).15 G .341(ashion upw)-2.941 F .342(ard-compatible with sh functions.)-.1 F .342(There are)5.342 F 1.447(certain shell v)72 358.8 R 1.446(ariables that Bash interprets in the same w)-.25 F 1.446(ay as sh, such as)-.1 F F2(PS1)3.946 E F0(,)A F2(IFS)3.946 E F0 3.946(,a)C(nd)-3.946 E F2 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446E 1.423(implements essentially the same grammar)72 370.8 R 3.924(,p)-.4G 1.424(arameter and v)-3.924 F 1.424(ariable e)-.25 F 1.424(xpansion semantics, redirection, and)-.15 F 1.06(quoting as the Bourne shell.)72 382.8 R 1.06(Where dif)6.06 F 1.06(ferences appear between the POSIX.2 standard and traditional sh)-.25 F(beha)72 394.8 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25E 1.608(The K)97 410.4 R 1.608(orn Shell \()-.35 F F2(ksh)A F0 4.108(\)i)C 4.108(sad)-4.108 G 1.608(escendent of the Bourne shell written at A)-4.108 F 1.609(T&T Bell Laboratories by)-1.11 F(Da)72 422.4 Q 1.059(vid K)-.2 F 3.559(orn\207. It)-.35 F(pro)3.559 E 1.059(vides a number of useful features that POSIX and Bash ha)-.15 F 1.359-.15(ve a)-.2 H 3.558(dopted. Man).15 F 3.558(yo)-.15 G 3.558(ft)-3.558G(he)-3.558 E(interacti)72 434.4 Q 1.312 -.15(ve f)-.25 H 1.012(acilities in POSIX.2 ha).05 F 1.312 -.15(ve t)-.2 H 1.012(heir roots in the ksh: for e).15 F 1.013(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 446.4 S .513(cilities are nearly identical. Bash includes features from the K).1 F.513(orn Shell for both interacti)-.35 F .813 -.15(ve u)-.25 H .513(se and shell).15 F 3.905(programming. F)72 458.4 R 1.405(or programming, Bash pro)-.15 F 1.405(vides v)-.15 F 1.405(ariables such as)-.25 F F2(RANDOM)3.905 E F0(and)3.905 E F2(REPL)3.905E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F2(typeset)3.905 E F0 -.2(bu)72470.4 S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398(ubstrings from v).15 F .398(ariables based on patterns, and shell arithmetic.)-.25 F F2(RANDOM)5.397 E F0 -.15(ex)72 482.4 S .489(pands to a random number each time it is referenced; assigning a v).15F .49(alue to)-.25 F F2(RANDOM)2.99 E F0 .49(seeds the random)2.99 F.055(number generator)72 494.4 R(.)-.55 E F2(REPL)5.055 E(Y)-.92 E F0.054(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25F F2 -.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2F .054(ariable names are sup-)-.25 F .742(plied as ar)72 506.4 R 3.243(guments. The)-.18 F F2(typeset)3.243 E F0 -.2(bu)3.243 G .743(iltin is used to de\214ne v).2 F .743(ariables and gi)-.25 F 1.043 -.15(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F2 -.18(re)3.243 G(ad-).18 E(only)72 518.4 Q F0 5.512(.B)C .512(ash arithmetic allo)-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511(luation of an e).25 F .511(xpression and the substitution of the result.)-.15 F .511(Shell v)5.511F(ari-)-.25 E .222(ables may be used as operands, and the result of an e)72 530.4 R .222(xpression may be assigned to a v)-.15 F 2.722(ariable. Nearly)-.25 F.222(all of)2.722 F(the operators from the C language are a)72 542.4 Q-.25(va)-.2 G(ilable, with the same precedence rules:).25 E/F3 10/Courier@0 SF 6($e)97 560.4 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 572.4Q F0 -.15(Fo)72 594 S 3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25H .74(se, Bash implements ksh-style aliases and b).15 F .74(uiltins such as)-.2 F F2(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74(w\) and)-.25 F F2(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 606 R2.791(was)-.25 G .291(tring to be substituted for a command name.)-2.791F(The)5.291 E 2.791(yc)-.15 G .291(an be used to create a mnemonic)-2.791 F .568(for a)72 618 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568(command name \()3.068 F F3 .568(alias del=rm)B F0 .568(\), to e)B .567(xpand a single w)-.15 F .567(ord to a comple)-.1 F 3.067(xc)-.15 G .567(ommand \()-3.067 F F3(alias)A .255(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 630 R F0 .255(\), or to ensure that a command)B(is in)72 642 Q -.2(vo)-.4 G -.1(ke).2G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F3(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 657.6 R F2(csh)A F0 .293(\)\207, originally written by Bill Jo)B 2.792(yw)-.1 G .292(hile at Berk)-2.792 F(ele)-.1 E 1.592 -.65(y, i)-.15 H 2.792(sw).65 G.292(idely used and quite popular)-2.792 F 1.499(for its interacti)72669.6 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499(includes a csh-compatible history e)3.999 F 1.5(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 681.6R .018(xpansion, access to a stack of directories via the)-.15 F F2(pushd)2.518 E F0(,)A F2(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F2(dirs)2.518 E F0 -.2(bu)2.518 G .018(iltins, and tilde e).2 F(xpansion,)-.15 E1.293(to generate users' home directories.)72 693.6 R -.35(Ti)6.294 G1.294(lde e).35 F 1.294(xpansion has also been adopted by both the K)-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 708.2 72 708.2 DL/F5 8/Times-Roman@0 SF(\207Morris Bolsk)72 720 Q 2(ya)-.12 G(nd Da)-2 E(vid K)-.16 E(orn,)-.28 E/F6 8/Times-Italic@0 SF(The K)2 E(ornShell Command and Pr)-.32 E -.08(og)-.36 G -.12(ra).08 G(mming Langua).12 E -.08(ge)-.08 G F5 2(,P).08 G(rentice Hall, 1989.)-2E EP%%Page: 3 3%%BeginPageSetupBP%%EndPageSetup/F0 10/Times-Roman@0 SF(-3-)282.17 48 Q(POSIX.2.)72 84 Q .148(There were certain areas in which POSIX.2 felt standardization w)9799.6 R .149(as necessary)-.1 F 2.649(,b)-.65 G .149(ut no e)-2.849 F.149(xisting imple-)-.15 F 1.598(mentation pro)72 111.6 R 1.598(vided the proper beha)-.15 F(vior)-.2 E 6.598(.T)-.55 G 1.598(he w)-6.598 F 1.597(orking group in)-.1 F -.15(ve)-.4 G 1.597(nted and standardized functionality in).15 F .674(these areas, which Bash implements.)72 123.6 R(The)5.674 E/F1 10/Times-Bold@0 SF(command)3.174 E F0 -.2(bu)3.174 G .674(iltin w).2 F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -