免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2151 | 回复: 1
打印 上一主题 下一主题

[其他] 关于循环读取的一个信息 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-01-23 11:25 |只看该作者 |倒序浏览
我有一个这样的shell:
while read filename
do
echo "db2 instname:"$filename

done<`ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq`



[db2inst1@localhost ~]$ while read filename
> do
> echo "db2 instname:"$filename
>
> done<`ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq`
-bash: `ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq`: ambiguous redirect
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq
db2inst1
root
[db2inst1@localhost ~]$

可是执行后报错:
-bash: `ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq`: ambiguous redirect

帮忙看下!谢谢!

论坛徽章:
39
辰龙
日期:2013-08-21 15:45:192015亚冠之广州富力
日期:2015-05-12 16:34:52亥猪
日期:2015-03-03 17:22:00申猴
日期:2015-03-03 17:21:37未羊
日期:2014-10-10 13:45:41戌狗
日期:2014-06-17 09:53:29巨蟹座
日期:2014-06-12 23:17:17双鱼座
日期:2014-06-10 12:42:44寅虎
日期:2014-06-09 12:52:172015亚冠之卡尔希纳萨夫
日期:2015-05-24 15:24:35黄金圣斗士
日期:2015-12-02 17:25:0815-16赛季CBA联赛之吉林
日期:2017-06-24 16:43:52
2 [报告]
发表于 2014-01-23 12:54 |只看该作者
回复 1# love2008
  1.     while read filename
  2. do
  3. echo "db2 instname:"$filename

  4. done< <(ps -ef|grep -i db2inst1|grep -v grep|awk '{ print $1 }'|sort|uniq)
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP