免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1856 | 回复: 4

大家帮忙看看个问题 [复制链接]

论坛徽章:
0
发表于 2011-08-18 10:57 |显示全部楼层
ls -al |grep txt结果:
-rw-r--r--   1 cbossapp   tong        790931 2010年4月29日 IP1.txt
-rw-r--r--   1 cbossapp   tong        790870 2010年4月29日 IPS504920100428.txt
-rw-r--r--   1 cbossapp   tong        790869 2010年4月29日 IPS5049201004280224.txt
-rw-r--r--   1 cbossapp   tong        790541 2010年4月29日 IPS5051201004280225.txt
我想练习使用下system函数,报错,咋就不能实现cp呢?
ls -al |grep txt|awk '{system("cp "$7 $7"bak")}'
用法:  cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file target_file
        cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file ... target_directory
        cp [-f|-i] [-p] [-S] -R|-r [-e warn|force|ignore] source_directory ... target_directory
        cp -R[-H | -L | -P] [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file ... target
        cp -r[-H | -L | -P] [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file ... target
加上-R也是报错

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 09:55:28
发表于 2011-08-18 11:03 |显示全部楼层
system("cp "$7" "$7"bak")

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
发表于 2011-08-18 11:05 |显示全部楼层
  1. ls -al *.txt |awk '{system ("cp "$7" "$7".bak")}'
复制代码

论坛徽章:
0
发表于 2011-08-18 11:32 |显示全部楼层
感谢各位

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
发表于 2011-08-18 11:37 |显示全部楼层
中间的两个$7中间请通过" "连接
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP