条件判断语法
[root@old_boyscripts]#catjudgehost.sh
#!/bin/bash
echo"pleaseinputipaddress:"
readip
[-n"`grep"$ip"/etc/hosts`"]&&\#注意前面的过滤条件结尾带有空格。
echo"Thehostnameis:`grep"$ip"/etc/hosts|awk'{print$2}'`"||\
echo"Theipisinvalid"
[ -n "ddd" ] && echo 1 || echo 0
三元运算符
awk 'BEGIN{a="b";print a=="b"?"ok":"err";}'
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。