高級bash腳本編程指南(外文文獻(xiàn)翻譯).doc
約25頁DOC格式手機(jī)打開展開
高級bash腳本編程指南(外文文獻(xiàn)翻譯),高級bash腳本編程指南一個對腳本編程技術(shù)的深入討論1:簡介shell是一個命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶之間的絕緣層,也是一種功能強(qiáng)大的編程語言。一個shell程序,通常被稱作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來的容易使用的工具。事實上,shell腳本可以調(diào)用整個unix系統(tǒng)命...
內(nèi)容介紹
此文檔由會員 wanli1988go 發(fā)布
高級Bash腳本編程指南
一個對腳本編程技術(shù)的深入討論
1:簡介
Shell是一個命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶之間的絕緣層,也是一種功能強(qiáng)大的編程語言。一個Shell程序,通常被稱作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來的容易使用的工具。事實上,shell腳本可以調(diào)用整個UNIX系統(tǒng)命令,軟件包和工具。如果這還不太夠的話,Shell的內(nèi)部命令,如測試和循環(huán)結(jié)構(gòu),都使得Shell腳本更強(qiáng)大和更有彈性。Shell腳本在管理系統(tǒng)任務(wù)中表現(xiàn)得非常出色,在對日常反復(fù)性的處理工作中避免使用那些結(jié)構(gòu)復(fù)雜的程序語言。
2:為什么要用Shell編程?
腳本應(yīng)用知識對希望精通系統(tǒng)管理的任何個人說是必需的,他實際上不想寫一個腳本程序。一般說一個Linux機(jī)器啟動后,它會執(zhí)行在/etc/rc.d 目錄下的Shell腳本重建系統(tǒng)環(huán)境并且啟動各種服務(wù)。理解這些啟動腳本的細(xì)節(jié)對分析系統(tǒng)運(yùn)作并修改它是有很大意義的。
編寫shell腳本并不難學(xué),因為腳本內(nèi)建的功能集(check?)和他們只要學(xué)相當(dāng)少的shell的操作符和選項。語法簡單易懂,像在命令行上調(diào)用和連接軟件包那樣容易,它只有少量的 "規(guī)則" 需要掌握。大多數(shù)短小的腳本第一次就工作的很好,較長的腳本調(diào)試也相當(dāng)?shù)娜菀住?br>shell腳本是個復(fù)雜應(yīng)用原型的"quick and dirty" 方法。在項目開發(fā)中用shell編程實現(xiàn)個有限的功能性子集是有用的開始。用這種方法去測試應(yīng)用程序的結(jié)構(gòu)和模塊組合,可以在實際地用C,C++,Java或者Perl進(jìn)行編程之前發(fā)現(xiàn)主要的設(shè)計缺陷。
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.
一個對腳本編程技術(shù)的深入討論
1:簡介
Shell是一個命令解釋器。它是操作系統(tǒng)內(nèi)核和用戶之間的絕緣層,也是一種功能強(qiáng)大的編程語言。一個Shell程序,通常被稱作為腳本,它是由系統(tǒng)調(diào)用,命令工具,軟件包和已編譯的二進(jìn)制包"結(jié)合" 起來的容易使用的工具。事實上,shell腳本可以調(diào)用整個UNIX系統(tǒng)命令,軟件包和工具。如果這還不太夠的話,Shell的內(nèi)部命令,如測試和循環(huán)結(jié)構(gòu),都使得Shell腳本更強(qiáng)大和更有彈性。Shell腳本在管理系統(tǒng)任務(wù)中表現(xiàn)得非常出色,在對日常反復(fù)性的處理工作中避免使用那些結(jié)構(gòu)復(fù)雜的程序語言。
2:為什么要用Shell編程?
腳本應(yīng)用知識對希望精通系統(tǒng)管理的任何個人說是必需的,他實際上不想寫一個腳本程序。一般說一個Linux機(jī)器啟動后,它會執(zhí)行在/etc/rc.d 目錄下的Shell腳本重建系統(tǒng)環(huán)境并且啟動各種服務(wù)。理解這些啟動腳本的細(xì)節(jié)對分析系統(tǒng)運(yùn)作并修改它是有很大意義的。
編寫shell腳本并不難學(xué),因為腳本內(nèi)建的功能集(check?)和他們只要學(xué)相當(dāng)少的shell的操作符和選項。語法簡單易懂,像在命令行上調(diào)用和連接軟件包那樣容易,它只有少量的 "規(guī)則" 需要掌握。大多數(shù)短小的腳本第一次就工作的很好,較長的腳本調(diào)試也相當(dāng)?shù)娜菀住?br>shell腳本是個復(fù)雜應(yīng)用原型的"quick and dirty" 方法。在項目開發(fā)中用shell編程實現(xiàn)個有限的功能性子集是有用的開始。用這種方法去測試應(yīng)用程序的結(jié)構(gòu)和模塊組合,可以在實際地用C,C++,Java或者Perl進(jìn)行編程之前發(fā)現(xiàn)主要的設(shè)計缺陷。
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.