免费注册 查看新帖 |

Chinaunix

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

无法得到awk的数值 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-09 21:56 |只看该作者 |倒序浏览
不知道是什么原因, 在rsh中无法得到awk的数值..
我的code是这样.....
1. echo "total file " >log
    rsh othersite "tar tvf /tmp/file.tar |wc|awk '{print $1}' " >>log
output:
total file  (本想output : total file 53)
        53

2. rsh othersite "echo total `tar tvf /tmp/file.tar |wc|awk '{print $1}' ` " >log
output:
tar: /tmp/file.tar : No such file
0: Command not found


不知为何在rsh中加上 ` 中就不行, 我以试过加{}, [], ()到, 还是不行, 请问有没有其他方法?

[ 本帖最后由 xmi 于 2008-10-9 22:03 编辑 ]

论坛徽章:
3
戌狗
日期:2014-09-10 17:07:162015年辞旧岁徽章
日期:2015-03-03 16:54:15wusuopu
日期:2016-06-17 17:43:45
2 [报告]
发表于 2008-10-09 23:22 |只看该作者
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc|awk '{print $1}' " >log
不过会多出两列数据:total file     723    4338   60822,怎么回事?
remote 主机本地执行结果:total file 723

论坛徽章:
0
3 [报告]
发表于 2008-10-09 23:51 |只看该作者
原帖由 ynchnluiti 于 2008-10-9 23:22 发表
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc|awk '{print $1}' " >log
不过会多出两列数据:total file     723    4338   60822,怎么回事?
remote 主机本地执行结果:total file 723


你可以试改一下为 wc -l .....
待我试试你的code...谢谢.

论坛徽章:
0
4 [报告]
发表于 2008-10-10 20:07 |只看该作者
原帖由 ynchnluiti 于 2008-10-9 23:22 发表
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc|awk '{print $1}' " >log
不过会多出两列数据:total file     723    4338   60822,怎么回事?
remote 主机本地执行结果:total file 723


今天试过了, 以command单独运行是成功, 但把它放入file.ksh中运行, 就有问题, 它会说awk missing parameter之类......
#!/usr/bin/ksh
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc -l | awk '{print $1}' " >log


怎么回事?

论坛徽章:
3
戌狗
日期:2014-09-10 17:07:162015年辞旧岁徽章
日期:2015-03-03 16:54:15wusuopu
日期:2016-06-17 17:43:45
5 [报告]
发表于 2008-10-12 17:47 |只看该作者
我这里没问题。
你先看看rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc -l" >log或者
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar " >log 的结果吧

[ 本帖最后由 ynchnluiti 于 2008-10-13 00:25 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2008-10-12 21:16 |只看该作者
原帖由 xmi 于 2008-10-10 20:07 发表


今天试过了, 以command单独运行是成功, 但把它放入file.ksh中运行, 就有问题, 它会说awk missing parameter之类......
#!/usr/bin/ksh
rsh remote "echo -n 'total file ' && tar tvf /tmp/file.tar |wc  ...

'{print \$1}'

try
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP