for
循环体
for i in *.zip
do
echo "$i"
done
declare -a testArray={"element1" "element2"}
echo ${testArray[0]}
for i in "${testArray[@]}"
do
echo "$i"
done
# write in file "testsplit.sh"
IFS=',' read -ra splitArray <<< "This,is,a,test"
for i in "${splitArray[@]}"
do
echo "$i"
done
$ bash testsplit.sh
This
is
a
test
某个bash命令,比如ls -l
存入变量,之后引用变量。
# 注意等号前后不能加空格
listOutput=`ls -l`
echo "$listOutput"
touch testfile
printf "hello\n" > testfile
printf "world\n" >> testfile
echo "myPassword" | sudo -S myCommond
2018年4月7日