Re: Delete file if it contains x y or z

2008-09-07 Thread Peter Scott
On Sat, 06 Sep 2008 16:01:08 +0100, brian54321uk wrote: Just tried this, nothing happened at all. Really. $ echo abc /tmp/bar/one $ echo xyz /tmp/bar/two $ echo ab..yz /tmp/bar/three $ ls /tmp/bar one three two $ cat /tmp/foo #!/usr/bin/perl use strict; use warnings; sub delete_containing

Re: Delete file if it contains x y or z

2008-09-06 Thread Aruna Goke
Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? If however, it would

Re: Delete file if it contains x y or z

2008-09-06 Thread Aruna Goke
brian54321uk wrote: Aruna Goke wrote: Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of

Re: Delete file if it contains x y or z

2008-09-06 Thread Dr.Ruud
brian54321uk schreef: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? I would use `grep -l` to get the list of filenames, and rm to unlink them. No Perl

Re: Delete file if it contains x y or z

2008-09-06 Thread John W. Krahn
Dr.Ruud wrote: brian54321uk schreef: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? I would use `grep -l` to get the list of filenames, and rm to unlink them.

Re: Delete file if it contains x y or z

2008-09-06 Thread John W. Krahn
Aruna Goke wrote: brian54321uk wrote: Aruna Goke wrote: Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the

Re: Delete file if it contains x y or z

2008-09-06 Thread brian54321uk
John W. Krahn wrote: Aruna Goke wrote: brian54321uk wrote: Aruna Goke wrote: Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be

Re: Delete file if it contains x y or z

2008-09-06 Thread brian54321uk
John W. Krahn wrote: Dr.Ruud wrote: brian54321uk schreef: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? I would use `grep -l` to get the list of filenames,

Re: Delete file if it contains x y or z

2008-09-06 Thread brian54321uk
Aruna Goke wrote: brian54321uk wrote: Aruna Goke wrote: Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the

Re: Delete file if it contains x y or z

2008-09-06 Thread Peter Scott
On Fri, 05 Sep 2008 19:09:25 +0100, brian54321uk wrote: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? One way: use strict; use warnings; sub

Re: Delete file if it contains x y or z

2008-09-06 Thread brian54321uk
Peter Scott wrote: On Fri, 05 Sep 2008 19:09:25 +0100, brian54321uk wrote: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? One way: use strict; use warnings;

Re: Delete file if it contains x y or z

2008-09-06 Thread brian54321uk
[EMAIL PROTECTED] wrote: Here's another way, but not necessarily the best Perl, but it does work: #!/usr/bin/env perl use strict; use warnings; my @filelist=STDIN; chomp @filelist; my $match_strings=qr '(abc123blue|xyz357green)'; my ($file, ); foreach $file (@filelist) { #print file=$file\n;

Re: Delete file if it contains x y or z

2008-09-06 Thread asmith9983
Here's another way, but not necessarily the best Perl, but it does work: #!/usr/bin/env perl use strict; use warnings; my @filelist=STDIN; chomp @filelist; my $match_strings=qr '(abc123blue|xyz357green)'; my ($file, ); foreach $file (@filelist) { #print file=$file\n; open(FD,$file) or die

Delete file if it contains x y or z

2008-09-05 Thread brian54321uk
HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? If however, it would be simpler for the script to empty the files contents, that's not a problem as I

Re: Delete file if it contains x y or z

2008-09-05 Thread Raja Vadlamudi
On Fri, Sep 5, 2008 at 2:09 PM, brian54321uk [EMAIL PROTECTED]wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? If however, it would be simpler

Re: Delete file if it contains x y or z

2008-09-05 Thread Mr. Shawn H. Corey
On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? If however, it would be simpler for the script

Re: Delete file if it contains x y or z

2008-09-05 Thread Jeff Pang
2008/9/6 Raja Vadlamudi [EMAIL PROTECTED]: for (glob(folder/*)) { unlink if m/abc123blue|xyz357green/; } This would also delete abc123blue.exe, abc123blue.txt, otherabc123blue etc. OP could consider to use File::Find to do that. -- Regards, Jeff. -- To unsubscribe, e-mail: [EMAIL