²Ù×÷ϵͳÓëÍⲿ×îÖ÷ÒªµÄ½Ó¿Ú¾Í½Ð×öshell¡£shellÊDzÙ×÷ϵͳ×îÍâÃæµÄÒ»²ã¡£shell¹ÜÀíÄãÓë²Ù×÷ϵͳ֮¼äµÄ½»»¥:µÈ´ýÄãÊäÈ룬Ïò²Ù×÷ϵͳ½âÊÍÄãµÄÊäÈ룬²¢ÇÒ´¦Àí¸÷ÖÖ¸÷ÑùµÄ²Ù×÷ϵͳµÄÊä³ö½á¹û¡£
shellÌṩÁËÄãÓë²Ù×÷ϵͳ֮¼äͨѶµÄ·½Ê½¡£ÕâÖÖͨѶ¿ÉÒÔÒÔ½»»¥·½Ê½£¨´Ó¼üÅÌÊäÈ룬²¢ÇÒ¿ÉÒÔÁ¢¼´µÃµ½ÏìÓ¦£©£¬»òÕßÒÔshell script(·Ç½»»¥)·½Ê½Ö´ÐС£shell scriptÊÇ·ÅÔÚÎļþÖеÄÒ»´®shellºÍ²Ù×÷ϵͳÃüÁËüÃÇ¿ÉÒÔ±»Öظ´Ê¹Óᣱ¾ÖÊÉÏ£¬shell scriptÊÇÃüÁîÐÐÃüÁî¼òµ¥µÄ×éºÏµ½Ò»¸öÎļþÀïÃæ¡£
½»»¥Ê½shellºÍ·Ç½»»¥Ê½shell
½»»¥Ê½Ä£Ê½¾ÍÊÇshellµÈ´ýÄãµÄÊäÈ룬²¢ÇÒÖ´ÐÐÄãÌá½»µÄÃüÁî¡£ÕâÖÖģʽ±»³Æ×÷½»»¥Ê½ÊÇÒòΪshellÓëÓû§½øÐн»»¥¡£ÕâÖÖģʽҲÊÇ´ó¶àÊýÓû§·Ç³£ÊìϤµÄ£ºµÇ¼¡¢Ö´ÐÐһЩÃüÁǩÍË¡£µ±ÄãÇ©Í˺ó£¬shellÒ²ÖÕÖ¹ÁË¡£
shellÒ²¿ÉÒÔÔËÐÐÔÚÁíÍâÒ»ÖÖģʽ£º·Ç½»»¥Ê½Ä£Ê½¡£ÔÚÕâÖÖģʽÏ£¬shell²»ÓëÄã½øÐн»»¥£¬¶øÊǶÁÈ¡´æ·ÅÔÚÎļþÖеÄÃüÁî,²¢ÇÒÖ´ÐÐËüÃÇ¡£µ±Ëü¶Áµ½ÎļþµÄ½á⣬shellÒ²¾ÍÖÕÖ¹ÁË¡£
shellµÄÀàÐÍ
ÔÚUNIXÖÐÖ÷ÒªÓÐÁ½´óÀàshell
Bourne shell (°üÀ¨ sh, ksh, and bash)
Bourne shell ( sh)
Korn shell ( ksh)
Bourne Again shell ( bash)
POSIX shell ( sh)
C shell (°üÀ¨ csh and tcsh)
C shell ( csh)
TENEX/TOPS C shell ( tcsh)
Bourne Shell
×î³õµÄUNIX shellÊÇÓÉStephen R. BourneÓÚ20ÊÀ¼Í70Äê´úÖÐÆÚÔÚÐÂÔóÎ÷µÄAT&T±´¶ûʵÑéÊÒ±àдµÄ£¬Õâ¾ÍÊÇBourne shell¡£Bourne shell ÊÇÒ»¸ö½»»»Ê½µÄÃüÁî½âÊÍÆ÷ºÍÃüÁî±à³ÌÓïÑÔ¡£Bourne shell ¿ÉÒÔÔËÐÐΪlogin shell»òÕßlogin shellµÄ×Óshell(subshell)¡£Ö»ÓÐloginÃüÁî¿ÉÒÔµ÷ÓÃBourne shell×÷Ϊһ¸ölogin shell¡£´Ëʱ£¬shellÏȶÁÈ¡/etc/profileÎļþºÍ$HOME/.profileÎļþ¡£/etc/profileÎļþΪËùÓеÄÓû§¶¨ÖÆ»·¾³,$HOME/.profileÎļþΪ±¾Óû§¶¨ÖÆ»·¾³¡£×îºó£¬shell»áµÈ´ý¶ÁÈ¡ÄãµÄÊäÈë¡£
C Shell
Bill JoyÓÚ20ÊÀ¼Í80Äê´úÔçÆÚ£¬ÔÚBerkeleyµÄ¼ÓÀû¸£ÄáÑÇ´óѧ¿ª·¢ÁËC shell¡£ËüÖ÷ÒªÊÇΪÁËÈÃÓû§¸üÈÝÒ×µÄʹÓý»»¥Ê½¹¦ÄÜ£¬²¢°ÑALGOL·ç¸ñµÄÓï·¨½á¹¹±ä³ÉÁËCÓïÑÔ·ç¸ñ¡£ËüÐÂÔöÁËÃüÁîÀúÊ·¡¢±ðÃû¡¢ÎļþÃûÌæ»»¡¢×÷Òµ¿ØÖƵȹ¦ÄÜ¡£
Korn Shell
Óкܳ¤Ò»¶Îʱ¼ä£¬Ö»ÓÐÁ½Ààshell¹©ÈËÃÇÑ¡Ôñ£¬Bourne shellÓÃÀ´±à³Ì£¬C shellÓÃÀ´½»»¥¡£ÎªÁ˸ıäÕâÖÖ×´¿ö£¬AT&TµÄbellʵÑéÊÒDavid Korn¿ª·¢ÁËKorn shell¡£ksh½áºÏÁËËùÓеÄC shellµÄ½»»¥Ê½ÌØÐÔ£¬²¢ÈÚÈëÁËBourne shellµÄÓï·¨¡£Òò´Ë£¬Korn shell¹ãÊÜÓû§µÄ»¶Ó¡£Ëü»¹ÐÂÔöÁËÊýѧ¼ÆËã,½ø³ÌÐ×÷(coprocess)¡¢ÐÐÄÚ±à¼(inline editing)µÈ¹¦ÄÜ¡£Korn Shell ÊÇÒ»¸ö½»»¥Ê½µÄÃüÁî½âÊÍÆ÷ºÍÃüÁî±à³ÌÓïÑÔ.Ëü·ûºÏPOSIX----Ò»¸ö²Ù×÷ϵͳµÄ¹ú¼Ê±ê×¼.POSIX²»ÊÇÒ»¸ö²Ù×÷ϵͳ,¶øÊÇÒ»¸öÄ¿±êÔÚÓÚÓ¦ÓóÌÐòµÄÒÆÖ²ÐԵıê×¼----ÔÚÔ´³ÌÐòÒ»¼¶¿çÔ½¶àÖÖƽ̨¡£
Bourne Again Shell (bash)
bashÊÇGNU¼Æ»®µÄÒ»²¿·Ö£¬ÓÃÀ´Ìæ´úBourne shell¡£ËüÓÃÓÚ»ùÓÚGNUµÄϵͳÈçLinux.´ó¶àÊýµÄLinux(Red Hat, Slackware, Caldera)¶¼ÒÔbash×÷ΪȱʡµÄshell£¬²¢ÇÒÔËÐÐshʱ£¬Æäʵµ÷ÓõÄÊÇbash¡£
POSIX Shell
POSIX shell ÊÇKorn shellµÄÒ»¸ö±äÖÖ. µ±Ç°ÌṩPOSIX shellµÄ×î´óÂôÖ÷ÊÇHewlett-Packard¡£ÔÚHP-UX 11.0 , POSIX shell ¾ÍÊÇ/bin/sh,¶øbshÊÇ/usr/old/bin/sh.
¸÷Ö÷Òª²Ù×÷ϵͳÏÂȱʡµÄshell:
AIX ÏÂÊÇKorn Shell.
SolarisºÍFreeBSDȱʡµÄÊÇBourne shell.
HP-UXȱʡµÄÊÇPOSIX shell.
LinuxÊÇBourne Again shell.
¡¾TIP¡¿
#!/usr/bin/shµÄÓÃ;
shell scriptµÄµÚÒ»ÐÐÒ»°ã¶¼ÊÇ#!/usr/bin/sh»ò#!/usr/bin/kshµÈ£¬ËüµÄÓÃ;¾ÍÊÇÖ¸³ö±¾½Å±¾ÊÇÓõÄÄÄÖÖshellдµÄ£¬Ö´ÐÐʱϵͳӦ¸ÃÓÃÄÄÖÖshellÀ´½âÊÍÖ´ÐÐËü¡£