touch :建立文件shell
nano:打開 編輯文件 ctrl+x 保存 y確認 vim
gedit編輯文件bash
1)編輯shell腳本:vim spa
2)運行腳本: /bin/sh 文件 ; 目錄下: ./ 文件it
3)每一個shell文件開頭 #!/bin/bash 使用這個/bin/bash 進行解析for循環
--------------------------------------for循環--------test
4)for循環 : for a in 1 2 3 4 ; do xxxx; done (結束)循環
5)傳入參數的shell腳本 for a in "$@" ; do echo $a ; done ----> "$@" 接受全部傳入的參數im
6) for(( exp1; exp2; exp3 )) ; do xxx ;done腳本
--------------------if判斷------------------for循環--------
6) if [[ $# -lt 1 ]] ; then echo no param; exit; fi -------> if----[[ 條件 ]] $# 傳入的參數個數 ; -lt : 小於(等於) ; then : 知足判斷條件; fi 不知足判斷條件
7)if [ a -lt b ] then xxx else xx fi
-------------------while循環----------------------------------------
-------------------------分號和換行-----------------------------------------------
8)shell腳本中 一句代碼 須要使用到 分號 可是若是一句代碼分爲換行 :該代碼若寫做多行,用換行符來區分代碼塊,則無需用到分號,例如:
if [ "PS1" ] > then echo "test is ok" > fi test is ok