#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
use File::Find;
our ($opt_d, $opt_e);
getopt("de");
die "exclude is not defined (no parameter for -e)" unless defined $opt_e;
our $dir = $opt_d;
die "$dir is not a directory (wrong parameter for -d)" unless -d $dir;
our @exclude = split /,/, $opt_e;
finddepth(\&wanted, "$dir");
sub wanted {
if (( ! grep {$File::Find::name eq "$dir/$_"} @exclude) && (-f $_)) {
unlink $_;
}
}
Hello,
I have several files in a specific directory.
A specific string in one file can occur in another files.
If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string.
Example.
file1
ShortName "Blue... (2 Replies)
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
How to delete last row in the file in PERL.
file1 has
a.output
b.output
c.output
d.output
e.output
expected output is
a.output
b.output
c.output
d.output (1 Reply)
Hi,
How to delete a file (if exists) using perl script.
I have used following script..
if ( -e $newfile) {
open (FILE, ">$newfile") || die "Cannot Open File\n";
print FILE;
close(FILE);
}
But it gives me error "Use of uninitialized value in print".
please help.
Thanks in... (1 Reply)
Hello All
I am implementing my task in Perl and i found an issue.
What i want to do is to remove files from the directory which were made 20 days back using Perl script (9 Replies)
I am trying to FTP files to a Windows server through my Linux machine. I have setup the file transfer with no problems but am having problem deleting those files from the Linux box. My current non-working solution is below. Any ideas, anyone?? :wall: Please be gentle, I'm fairly new to this... (4 Replies)
Hi All,
I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet
#Script Starts here
#!/usr/local/bin/perl
#Program to find the disk space and to delete the older files
#Checks the type of OS... (8 Replies)
he following are the files available in my directory
RSK_123_20141113_031500.txt
RSK_123_20141113_081500.txt
RSK_126_20141113_041500.txt
RSK_126_20141113_081800.txt
RSK_128_20141113_091600.txt
Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies
LEARN ABOUT REDHAT
extutils::installed
ExtUtils::Installed(3pm) Perl Programmers Reference Guide ExtUtils::Installed(3pm)NAME
ExtUtils::Installed - Inventory management of installed modules
SYNOPSIS
use ExtUtils::Installed;
my ($inst) = ExtUtils::Installed->new();
my (@modules) = $inst->modules();
my (@missing) = $inst->validate("DBI");
my $all_files = $inst->files("DBI");
my $files_below_usr_local = $inst->files("DBI", "all", "/usr/local");
my $all_dirs = $inst->directories("DBI");
my $dirs_below_usr_local = $inst->directory_tree("DBI", "prog");
my $packlist = $inst->packlist("DBI");
DESCRIPTION
ExtUtils::Installed provides a standard way to find out what core and module files have been installed. It uses the information stored in
.packlist files created during installation to provide this information. In addition it provides facilities to classify the installed
files and to extract directory information from the .packlist files.
USAGE
The new() function searches for all the installed .packlists on the system, and stores their contents. The .packlists can be queried with
the functions described below.
FUNCTIONS
new()
This takes no parameters, and searches for all the installed .packlists on the system. The packlists are read using the ExtU-
tils::packlist module.
modules()
This returns a list of the names of all the installed modules. The perl 'core' is given the special name 'Perl'.
files()
This takes one mandatory parameter, the name of a module. It returns a list of all the filenames from the package. To obtain a list
of core perl files, use the module name 'Perl'. Additional parameters are allowed. The first is one of the strings "prog", "doc" or
"all", to select either just program files, just manual files or all files. The remaining parameters are a list of directories. The
filenames returned will be restricted to those under the specified directories.
directories()
This takes one mandatory parameter, the name of a module. It returns a list of all the directories from the package. Additional
parameters are allowed. The first is one of the strings "prog", "doc" or "all", to select either just program directories, just manual
directories or all directories. The remaining parameters are a list of directories. The directories returned will be restricted to
those under the specified directories. This method returns only the leaf directories that contain files from the specified module.
directory_tree()
This is identical in operation to directories(), except that it includes all the intermediate directories back up to the specified
directories.
validate()
This takes one mandatory parameter, the name of a module. It checks that all the files listed in the modules .packlist actually exist,
and returns a list of any missing files. If an optional second argument which evaluates to true is given any missing files will be
removed from the .packlist
packlist()
This returns the ExtUtils::Packlist object for the specified module.
version()
This returns the version number for the specified module.
EXAMPLE
See the example in ExtUtils::Packlist.
AUTHOR
Alan Burlison <Alan.Burlison@uk.sun.com>
perl v5.8.0 2002-06-01 ExtUtils::Installed(3pm)