免费注册 查看新帖 |

Chinaunix

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

求助:perl怎么删除a*.txt文件? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-17 11:34 |只看该作者 |倒序浏览
unlink?
不能像shell那样是用通配符阿

论坛徽章:
0
2 [报告]
发表于 2006-08-17 11:44 |只看该作者
unlink 可以通配符呀

       unlink LIST
       unlink  Deletes a list of files.  Returns the number of files success-
               fully deleted.

                   $cnt = unlink ’a’, ’b’, ’c’;
                   unlink @goners;
                   unlink <*.bak>;

               Note: "unlink" will not delete directories unless you are supe-
               ruser and the -U flag is supplied to Perl.  Even if these con-
               ditions are met, be warned that unlinking a directory can
               inflict damage on your filesystem.  Use "rmdir" instead.

               If LIST is omitted, uses $_.

论坛徽章:
0
3 [报告]
发表于 2006-08-17 11:46 |只看该作者

  1.       1 #! /usr/bin/perl -w
  2.       2 #
  3.       3
  4.       4 use strict;
  5.       5
  6.       6 unlink(<ou*>);
  7.       7

复制代码

论坛徽章:
0
4 [报告]
发表于 2006-08-17 11:54 |只看该作者
原帖由 wangrujun 于 2006-8-17 11:44 发表
unlink 可以通配符呀

       unlink LIST
       unlink  Deletes a list of files.  Returns the number of files success-
               fully deleted.

                   $cnt = unlink ’a’, ’ ...

谢谢啦。
顺便问下File::Copy可以使用通配符吗?

论坛徽章:
0
5 [报告]
发表于 2006-08-17 11:55 |只看该作者
都可以的

论坛徽章:
0
6 [报告]
发表于 2006-08-17 12:54 |只看该作者
原帖由 wangrujun 于 2006-8-17 11:55 发表
都可以的

use File::Copy;

copy("a*.txt", "/export/home/mavina");

不行啊,没拷过去

论坛徽章:
0
7 [报告]
发表于 2006-08-17 13:20 |只看该作者
噢,perl 的copy只支持标量,所以不支持通配符.

`cp a*.txt /export`;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP