標籤:如果運算式中包含特殊字元,Shell 將會進行替換。例如,在雙引號中使用變數就是一種替換,逸出字元也是一種替換。舉個例子:#!/bin/basha=10echo -e "Value of a is $a \n"運行結果:Value of a is 10這裡 -e 表示對逸出字元進行替換。如果不使用 -e 選項,將會原樣輸出:Value of a is 10\n下面的逸出字元都可以用在 echo
標籤:shell#!/bin/bash#斐波那契數列#不要用遞迴,深度大於30就老火了。function fun_test(){ if [ $1 -lt 3 ];then echo 1 return fi sum1=1 sum2=1 let count=$1-2 sum=0 while [ $count -gt 0 ];do let count-- let sum=sum1+sum2 let
標籤:for迴圈的文法:1. for 變數 in 值1 值2 值3.... do 程式 done例如:下列指令碼會分別列印4次 分別是morning noon afternoon evening的值1 #!/bin/bash2 #列印時間3 #Author Mrfeng4 5 for time in morning noon afternoon evening6 do7 echo $time8
標籤:shell stdin if bash file 4.輸入輸出#! /bin/bash# Read users input and then get his nameread -p "Please input your first name: " firstNameread -p "Please input your
標籤:shell指令碼檢查memcache修正版:#!/bin/sh#check memcache process and restart if downmm_bin="/usr/local/bin/memcached"mm_log="/home/xxx/memcached_check.log"mm_ports=("11211" "11212")mm_param=("-d -m 20480 -p 11211
Shell指令碼編程篇,shell指令碼編程 #!/bin/bash#斐波那契數列#不要用遞迴,深度大於30就老火了。function fun_test(){ if [ $1 -lt 3 ];then echo 1 return fi sum1=1 sum2=1 let count=$1-2 sum=0 while [ $count -gt 0 ];do let count-- let