歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux學習輔導總結17

Linux學習輔導總結17

日期:2017/2/25 10:36:01   编辑:Linux教程
Shell腳本
1、shell腳本的特點:
(1)shell腳本相當於DOS中的批處理文件,是多個命令的集合
(2)shell腳本保存在文本文件中,我們可以對其進行閱讀和編輯
(3)shell腳本由Shell環境解釋執行的,不需要在執行前進行編譯
(4)shell腳本執行Shell程序時,Shell腳本文件需要具有可執行(X)的屬性

2、基本腳本編程
(1)建立Shell文件
如:vi hello.sh中華考試網(www.Examw。com)
(2)腳本運行環境設置
如:#!/bin/bash (注:“#!”與路徑名之間沒有空格)
(3)注釋行的使用
以“#”符開始,只是起解釋說明的作用
如:# This is my first HelloWorld program
(4)腳本語句
腳本語句的內容就是我們根據需要實現某種功能而輸入的一些命令集合
如:mkdir /root/aaa
touch /root/aaa/test
echo Hello!

3、腳本運行的方法(如:hello.sh為腳本文件)
(1)bash hello.sh (不需要可執行屬性)
(2) .hello.sh (不需要可執行屬性)
(3)./hello.sh (相對路徑,需要可執行屬性)
(4)/root/hello.sh (絕對路徑,需要可執行屬性)
Copyright © Linux教程網 All Rights Reserved