输出a到z
for i in {a..z}
do
echo $i
done
把ls /root的文件一个一个地输出:
[root@u ~]# cat 11.sh
for i in `ls /root`
do
echo $i
done
[root@u ~]#
&> /dev/dull中&>意思是把左边输出的结果,都放到/dev/dull文件中
[root@u ~]# cat 12.sh
for i in {1..253}
do
ping -c1 192.168.88.$i &> /dev/dull
if [ $? -ne 0 ]
then
echo "192.168.88.$i is available."
fi
done
[root@u ~]#
echo "192.168.88.$i is available." >> /root/ip.txt意思是把可用的IP放到文件ip.txt中
[root@u ~]# cat 12.sh
for i in {1..253}
do
ping -c1 192.168.88.$i &> /dev/dull
if [ $? -ne 0 ]
then
echo "192.168.88.$i is available." >> /root/ip.txt
# else
# echo "192.168.88.$i is unavailable."
fi
done
[root@u ~]#
case 语法python没有,其他有
[root@u ~]# cat 13.sh
read -p ‘input you name:‘ name
case $name in
root)
echo "welcome $name"
;;
seker)
echo "welcome $name"
;;
default)
echo "welcome $name"
;;
*)
echo "no $name "
esac
[root@u ~]#