整理了几个:
1、
[neo]$ awk 'BEGIN{a=system("test -f /etc/passwdd");if(a) {print "file not exist!";exit}}{print $1}' /etc/passwd
file not exist!
2、
[neo]$ awk 'BEGIN{if(system("test -f /etc/passwdd")) {print "file not exist!";exit}}{print $1}' /etc/passwd
file not exist!
3、
[neo]$ awk 'BEGIN{if((getline<"/etc/passwdd")==-1) {print "file not exist!";exit}}{print $1}' /etc/passwd
file not exist!
4、
[neo]$ awk '{"[ -e /etc/passwdd ]&&echo 1||echo 0"|getline a;if(!a) {print "error";exit}}{print $1}' /etc/passwd
error
阅读(3154) | 评论(1) | 转发(0) |