Linux bash基本语法

bash基本语法

#! /bin/bash
user=bash
echo "Welcome" $user

echo "If Else"
if ls -l devcpp.lnk; then
	echo "    ls true"
else
	echo "    ls false"
fi

if [ "$1" = "me" ]; then
	echo "    input me"
else
	echo "    not me"
fi


echo "For loop"
echo "for Method 1"
for num in 1 2 3
do
	echo "    num=$num"
done
echo "for Method 2"
for((num=1;num<4;num++))
do
	echo "    num=$num"
done

echo "While loop"
i=1
while [ "$i" -lt 4 ]
do
	echo "    num=$i"
	((i++))
done

你可能感兴趣的:(Linux,bash,.sh)