shell命令學習之for
for 變數 in 值
do宣告
done
例子:for a in a b x
do
echo $a
done
輸出:abx
while do 命令學習
#!/bin/sh
echo "請輸入密碼"
read trythis
while [ "$trythis" != "s" ]; do
echo "sorry you type word is increcct"
read trythis
done
exit 0
#!/bin/sh
echo "case測試"
read day
case "$day" in
yes|y|yes) echo "right";;
n*|n*) echo "wrong";;
esac
exit 0
&& 以及||學習
touch file_one
touch file_two
if [ -f file_one ] && echo "hello" && [ -f file_two ] && echo " there"
then
echo "in if"
else
echo "in else"
fiexit 0
執行./bin.sh param
param引數需要 $1 $2來接受引數
-----函式學習
#!/bin/sh
foo()
echo "start exe script"
if foo "$1"
then
read name
echo "你好,$1,很好的名字"
else
echo "無所謂"
fiexit 0
簡單shell命令學習(一)
shell 是乙個用 c 語言編寫的程式,它是使用者使用 linux 的橋梁。shell 既是一種命令語言,又是一種程式語言。shell 是指一種應用程式,這個應用程式提供了乙個介面,使用者通過這個介面訪問作業系統核心的服務。ken thompson 的 sh 是第一種 unix shell,win...
Shell命令學習
i 1001 for x in xml do mv x xml i done 注意i左右不可以有空格for x in do mv x x 1 done 在名字末尾加上數字1 2.將檔案名字提取並儲存 ls xml test.txt3.批量刪除檔案字尾名 rename s jpg 更多rename操作...
Shell命令學習(四)
if語句格式 if condition then command1 command2 commandn fiif else語句格式 if condition then command1 command2 commandn else command fi例項 bin bash a 20 b 30 if...