高級(jí)bash腳本編程指南(外文文獻(xiàn)翻譯).doc
約25頁(yè)DOC格式手機(jī)打開(kāi)展開(kāi)
高級(jí)bash腳本編程指南(外文文獻(xiàn)翻譯),高級(jí)bash腳本編程指南一個(gè)對(duì)腳本編程技術(shù)的深入討論1:簡(jiǎn)介shell是一個(gè)命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶(hù)之間的絕緣層,也是一種功能強(qiáng)大的編程語(yǔ)言。一個(gè)shell程序,通常被稱(chēng)作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來(lái)的容易使用的工具。事實(shí)上,shell腳本可以調(diào)用整個(gè)unix系統(tǒng)命...


內(nèi)容介紹
此文檔由會(huì)員 wanli1988go 發(fā)布
高級(jí)Bash腳本編程指南
一個(gè)對(duì)腳本編程技術(shù)的深入討論
1:簡(jiǎn)介
Shell是一個(gè)命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶(hù)之間的絕緣層,也是一種功能強(qiáng)大的編程語(yǔ)言。一個(gè)Shell程序,通常被稱(chēng)作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來(lái)的容易使用的工具。事實(shí)上,shell腳本可以調(diào)用整個(gè)UNIX系統(tǒng)命令,軟件包和工具。如果這還不太夠的話(huà),Shell的內(nèi)部命令,如測(cè)試和循環(huán)結(jié)構(gòu),都使得Shell腳本更強(qiáng)大和更有彈性。Shell腳本在管理系統(tǒng)任務(wù)中表現(xiàn)得非常出色,在對(duì)日常反復(fù)性的處理工作中避免使用那些結(jié)構(gòu)復(fù)雜的程序語(yǔ)言。
2:為什么要用Shell編程?
腳本應(yīng)用知識(shí)對(duì)希望精通系統(tǒng)管理的任何個(gè)人說(shuō)是必需的,他實(shí)際上不想寫(xiě)一個(gè)腳本程序。一般說(shuō)一個(gè)Linux機(jī)器啟動(dòng)后,它會(huì)執(zhí)行在/etc/rc.d 目錄下的Shell腳本重建系統(tǒng)環(huán)境并且啟動(dòng)各種服務(wù)。理解這些啟動(dòng)腳本的細(xì)節(jié)對(duì)分析系統(tǒng)運(yùn)作并修改它是有很大意義的。
編寫(xiě)shell腳本并不難學(xué),因?yàn)槟_本內(nèi)建的功能集(check?)和他們只要學(xué)相當(dāng)少的shell的操作符和選項(xiàng)。語(yǔ)法簡(jiǎn)單易懂,像在命令行上調(diào)用和連接軟件包那樣容易,它只有少量的 "規(guī)則" 需要掌握。大多數(shù)短小的腳本第一次就工作的很好,較長(zhǎng)的腳本調(diào)試也相當(dāng)?shù)娜菀住?br>shell腳本是個(gè)復(fù)雜應(yīng)用原型的"quick and dirty" 方法。在項(xiàng)目開(kāi)發(fā)中用shell編程實(shí)現(xiàn)個(gè)有限的功能性子集是有用的開(kāi)始。用這種方法去測(cè)試應(yīng)用程序的結(jié)構(gòu)和模塊組合,可以在實(shí)際地用C,C++,Java或者Perl進(jìn)行編程之前發(fā)現(xiàn)主要的設(shè)計(jì)缺陷。
Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting
1. Introduction
The shell is a command interpreter. More than just the insulating layer between the operating system kernel and the user, it's also a fairly powerful programming language. A shell program, called a script, is an easy-to-use tool for building applications by "gluing" together system calls, tools, utilities, and compiled binaries. Virtually the entire repertoire of UNIX commands, utilities, and tools is available for invocation by a shell script. If that were not enough, internal shell commands, such as testing and loop constructs, give additional power and flexibility to scripts. Shell scripts lend themselves exceptionally well to administrative system tasks and other routine repetitive jobs not requiring the bells and whistles of a full-blown tightly structured programming language.
2. Why Shell Programming?
A working knowledge of shell scripting is essential to anyone wishing to become reasonably proficient at system administration, even if they do not anticipate ever having to actually write a script. Consider that as a Linux machine boots up, it executes the shell scripts in /etc/rc.d to restore the system configuration and set up services. A detailed understanding of these startup scripts is important for analyzing the behavior of a system, and possibly modifying it.
Writing shell scripts is not hard to learn, since the scripts can be built in bite-sized sections and there is only a fairly small set of shell-specific operators and options to learn. The syntax is simple and straightforward, similar to that of invoking and chaining together utilities at the command line, and there are only a few "rules" to learn. Most short scripts work right the first time, and debugging even the longer ones is straightforward.
一個(gè)對(duì)腳本編程技術(shù)的深入討論
1:簡(jiǎn)介
Shell是一個(gè)命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶(hù)之間的絕緣層,也是一種功能強(qiáng)大的編程語(yǔ)言。一個(gè)Shell程序,通常被稱(chēng)作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來(lái)的容易使用的工具。事實(shí)上,shell腳本可以調(diào)用整個(gè)UNIX系統(tǒng)命令,軟件包和工具。如果這還不太夠的話(huà),Shell的內(nèi)部命令,如測(cè)試和循環(huán)結(jié)構(gòu),都使得Shell腳本更強(qiáng)大和更有彈性。Shell腳本在管理系統(tǒng)任務(wù)中表現(xiàn)得非常出色,在對(duì)日常反復(fù)性的處理工作中避免使用那些結(jié)構(gòu)復(fù)雜的程序語(yǔ)言。
2:為什么要用Shell編程?
腳本應(yīng)用知識(shí)對(duì)希望精通系統(tǒng)管理的任何個(gè)人說(shuō)是必需的,他實(shí)際上不想寫(xiě)一個(gè)腳本程序。一般說(shuō)一個(gè)Linux機(jī)器啟動(dòng)后,它會(huì)執(zhí)行在/etc/rc.d 目錄下的Shell腳本重建系統(tǒng)環(huán)境并且啟動(dòng)各種服務(wù)。理解這些啟動(dòng)腳本的細(xì)節(jié)對(duì)分析系統(tǒng)運(yùn)作并修改它是有很大意義的。
編寫(xiě)shell腳本并不難學(xué),因?yàn)槟_本內(nèi)建的功能集(check?)和他們只要學(xué)相當(dāng)少的shell的操作符和選項(xiàng)。語(yǔ)法簡(jiǎn)單易懂,像在命令行上調(diào)用和連接軟件包那樣容易,它只有少量的 "規(guī)則" 需要掌握。大多數(shù)短小的腳本第一次就工作的很好,較長(zhǎng)的腳本調(diào)試也相當(dāng)?shù)娜菀住?br>shell腳本是個(gè)復(fù)雜應(yīng)用原型的"quick and dirty" 方法。在項(xiàng)目開(kāi)發(fā)中用shell編程實(shí)現(xiàn)個(gè)有限的功能性子集是有用的開(kāi)始。用這種方法去測(cè)試應(yīng)用程序的結(jié)構(gòu)和模塊組合,可以在實(shí)際地用C,C++,Java或者Perl進(jìn)行編程之前發(fā)現(xiàn)主要的設(shè)計(jì)缺陷。
Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting
1. Introduction
The shell is a command interpreter. More than just the insulating layer between the operating system kernel and the user, it's also a fairly powerful programming language. A shell program, called a script, is an easy-to-use tool for building applications by "gluing" together system calls, tools, utilities, and compiled binaries. Virtually the entire repertoire of UNIX commands, utilities, and tools is available for invocation by a shell script. If that were not enough, internal shell commands, such as testing and loop constructs, give additional power and flexibility to scripts. Shell scripts lend themselves exceptionally well to administrative system tasks and other routine repetitive jobs not requiring the bells and whistles of a full-blown tightly structured programming language.
2. Why Shell Programming?
A working knowledge of shell scripting is essential to anyone wishing to become reasonably proficient at system administration, even if they do not anticipate ever having to actually write a script. Consider that as a Linux machine boots up, it executes the shell scripts in /etc/rc.d to restore the system configuration and set up services. A detailed understanding of these startup scripts is important for analyzing the behavior of a system, and possibly modifying it.
Writing shell scripts is not hard to learn, since the scripts can be built in bite-sized sections and there is only a fairly small set of shell-specific operators and options to learn. The syntax is simple and straightforward, similar to that of invoking and chaining together utilities at the command line, and there are only a few "rules" to learn. Most short scripts work right the first time, and debugging even the longer ones is straightforward.