最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

UNIX/Linux 系統(tǒng)管理技術(shù)手冊(cè)閱讀(十一)

2021-07-30 13:20 作者:Vecloud_  | 我要投稿


2016.11.7?
2 Scripting and the Shell?
Good system administrators write scripts. Scripts standardize and automate the performance of administrative chores and free up admins’ time for more important and more interesting tasks. In a sense, scripts are also a kind of low-rent documentation in that they act as an authoritative outline of the steps needed to complete a particular task.?
?好的系統(tǒng)管理員都要寫腳本。腳本以標(biāo)準(zhǔn)和自動(dòng)的方式履行系統(tǒng)管理員的繁雜事務(wù),藉此把管理員的時(shí)間節(jié)省出來(lái),以花在更重要和更有意思的任務(wù)上。從某種意思上講,腳本也是一種低質(zhì)量的文檔,因?yàn)樗鼈兂洚?dāng)了一種權(quán)威提綱,提綱里列出完成特殊任務(wù)所需的步驟。?
In terms of complexity, administrative scripts run the gamut from simple ones that encapsulate a few static commands to major software projects that manage host configurations and administrative data for an entire site. In this book we’re primarily interested in the smaller, day-to-day scripting projects that sysadmins normally encounter, so we don’t talk much about the support functions (e.g., bug tracking and design review) that are needed for larger projects.?
?從復(fù)雜性來(lái)看,系統(tǒng)管理腳本的范圍很廣,簡(jiǎn)單得只封裝幾條靜態(tài)命令,大到一處重要的軟件項(xiàng)目,為整個(gè)站點(diǎn)管理主機(jī)配置和管理性數(shù)據(jù)。在本書(shū)里,我們所感興趣的主要是系統(tǒng)管理員通常會(huì)碰到的較小的日常腳本項(xiàng)目。因此,對(duì)于大的項(xiàng)目才需要的支持功能(例如,bug追蹤和設(shè)計(jì)評(píng)審),我們不會(huì)講得太多。?
Administrative scripts should emphasize programmer efficiency and code clarity rather than computational efficiency. This is not an excuse to be sloppy, but simply a recognition that it rarely matters whether a script runs in half a second or two seconds. Optimization can have an amazingly low return on investment, even for scripts that run regularly out of cron.?
?系統(tǒng)管理腳本應(yīng)該注重兩點(diǎn),即編程人員的開(kāi)發(fā)效率和代碼的清晰可讀性。計(jì)算效率不應(yīng)該成為關(guān)注重點(diǎn),但這不應(yīng)該成為草率行事的借口,而是要認(rèn)識(shí)到,很少需要在意一個(gè)腳本是在半秒還是兩秒內(nèi)運(yùn)行完。優(yōu)化腳本獲得的回報(bào)都非常低,甚至對(duì)通過(guò)cron定期運(yùn)行的腳本來(lái)說(shuō)也不例外。?
For a long time, the standard language for administrative scripts was the one defined by the shell. Most systems’ default shell is bash (the “Bourne-again” shell),but sh (the original Bourne shell) and ksh (the Korn shell) are used on a few UNIX systems. Shell scripts are typically used for light tasks such as automating a sequence of commands or assembling several filters to process data.?
?長(zhǎng)期以來(lái),編寫系統(tǒng)管理腳本的標(biāo)準(zhǔn)語(yǔ)言是shell所定義的語(yǔ)言。在大多數(shù)系統(tǒng)上,默認(rèn)的shell都是由bash(即“Bourne agin”shell),但是在幾種不多的UNIX系統(tǒng)上,也用sh(最初的Bourne shell)和ksh(Korn shell)。shell腳本一般用于輕量級(jí)的任務(wù),如自動(dòng)執(zhí)行一系列命令,或者把幾個(gè)過(guò)濾器組合起來(lái)處理數(shù)據(jù)。?
The shell is always available, so shell scripts are relatively portable and have few dependencies other than the commands they invoke. Whether or not you choose the shell, the shell may choose you: most environments include a hefty complement of existing sh scripts, and those scripts frequently need to be read, understood, and tweaked by administrators.?
?各種操作系統(tǒng)上都有shell,所以shell腳本可移值性相當(dāng)好,除了它們調(diào)用的命令之外,要依賴的東西也不多。無(wú)論是否選擇shell來(lái)編寫腳本,都會(huì)碰到shell;大多數(shù)環(huán)境都包括已有sh腳本的強(qiáng)大補(bǔ)充,系統(tǒng)管理員會(huì)頻頻閱讀、理解和調(diào)整這些腳本。?
For more sophisticated scripts, it’s advisable to jump to a real programming language such as Perl or Python, both of which are well suited for administrative work. These languages incorporate a couple of decades’ worth of language design advancements relative to the shell, and their text processing facilities (invaluable to administrators) are so powerful that sh can only weep and cower in shame.?
?對(duì)于更為復(fù)雜高端的腳本來(lái)說(shuō),建議轉(zhuǎn)而采用一種真正的編程語(yǔ)言來(lái)寫,像perl或者python這樣的語(yǔ)言,它們兩者都很適合于系統(tǒng)管理工作。這兩種語(yǔ)言融入的設(shè)計(jì)理念比shell領(lǐng)先20年,它們的字處理功能(對(duì)于系統(tǒng)管理員來(lái)說(shuō),價(jià)值難以估量)如此強(qiáng)大,sh在它們面前黯然失色。?
The main drawback to Perl and Python is that their environments can be a bit?
fussy to set up, especially when you start to use third-party libraries that have compiled components. The shell skirts this particular issue by having no module structure and no third-party libraries.?
?Perl和Python的主要缺點(diǎn)在于,建立它們的環(huán)境要麻煩一點(diǎn),尤其是要用到的第三方庫(kù),而庫(kù)里又包含已經(jīng)編譯好的部件的時(shí)候。shell沒(méi)有模塊結(jié)構(gòu),也沒(méi)有第三方的庫(kù),因此避開(kāi)了這個(gè)特殊的問(wèn)題。?
This chapter takes a quick look at bash, Perl, and Python as languages for scripting, along with regular expressions as a general technology.?
?本章簡(jiǎn)要介紹了bash、Perl和Python作為腳本編程語(yǔ)言的用法,以及正則表達(dá)式這種通用的技術(shù)。?


2.1 SHELL BASICS?
Before we take up shell scripting, let’s review some of the basic features and syntax of the shell. The material in this section applies to all major shells in the sh lineage (including bash and ksh, but not csh or tcsh), regardless of the exact platform you are using. Try out the forms you’re not familiar with, and experiment!?
2.1 shell的基礎(chǔ)知識(shí)?
?在我們開(kāi)始介紹Shell的腳本編輯之前,讓我們先看看shell的一此基本特性和語(yǔ)法。不管讀者正在使用的是何種平臺(tái),本節(jié)都適用于sh大家庭里的所有主流shell(包括bash和ksh,但不包括csh或者tesh)。嘗試一下自己不熟悉的sh形式,做做實(shí)驗(yàn)吧!

了解更多網(wǎng)絡(luò)知識(shí)關(guān)注:http://www.vecloud.com/

UNIX/Linux 系統(tǒng)管理技術(shù)手冊(cè)閱讀(十一)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
靖安县| 错那县| 龙江县| 嘉鱼县| 安新县| 正镶白旗| 西乌珠穆沁旗| 云南省| 同心县| 三台县| 沭阳县| 景谷| 永新县| 周至县| 扶余县| 视频| 商南县| 武邑县| 固安县| 贺兰县| 邳州市| 芷江| 南宫市| 法库县| 西昌市| 明星| 阜平县| 石棉县| 梅河口市| 庆城县| 平凉市| 玛沁县| 凤台县| 大冶市| 石台县| 永丰县| 鹿泉市| 比如县| 萍乡市| 确山县| 新绛县|