Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3391808
  • 博文数量: 534
  • 博客积分: 11595
  • 博客等级: 上将
  • 技术积分: 5785
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-22 17:00
文章分类

全部博文(534)

文章存档

2015年(4)

2014年(27)

2013年(15)

2012年(38)

2011年(36)

2010年(85)

2009年(63)

2008年(142)

2007年(124)

分类:

2010-11-23 16:49:15

整理了几个:
 
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
阅读(3093) | 评论(1) | 转发(0) |
0

上一篇:awk定义局部变量

下一篇: awk使用大全(转)

给主人留下些什么吧!~~

chinaunix网友2010-11-24 13:19:30

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com