he below looks in $dir for any pattern of fileone. As is, it executes but only returns File found if the exact format in the script exsists. Why isn't a pattern of fileone being looked for and if it is in [CODE]$dir[/ICODE], File found. I think that is what should happen. Thank you .
Last edited by cmccabe; 11-15-2019 at 04:37 PM..
Reason: fixed format
Hello friends,
I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed.
My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc..
I... (6 Replies)
cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/
cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/
Before copying the files I have to check if the directory $DATE1 and $DATE2 exists.
If directory exists then, check if the folder contains some files.
if the file exists then, check if the file size is greater... (3 Replies)
Hi,
I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg.
"this is the line1"
"this is the line2"
The yyy.txt with lot of lines. eg:
"This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Hi ! All
I just want to search and write to new file if pattern is found in text file
following are my text files by which I want to search Month and last column number
my text file1
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25... (3 Replies)
Hi Gurus,
I have a requests to find if all the file in the filelist exist in certain directory.
example:
my filelist
abc
def
ddd
cde
afg
how can I find these 5 files exists at director /home/abc
Thanks in advance (7 Replies)
Hi guys,
I am beginner trying to learn unix. So any help is welcomed.
My requirement is to check whether is a file exists in a particular directory or not.
The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
I have many files that can have various amounts of rows. I essentially want to output each row into a new file if a pattern is matched between two files.
I have some code that does something similar but I want it to output every single input row from every file into a separate output file; that... (5 Replies)
Hi experts,
I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg
searchfile.dat will have
abc303
xyz123
i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz
The following code... (2 Replies)
There are some files with suffix dates like abc_20032019.dat abc_17032019.dat
If at least one file exists then perform some operation else exit from execution.
Korn shell
----------------------------------
array=($inputdir/abc*.dat)
If ] ]
then
echo " file exits"
else
echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies
LEARN ABOUT DEBIAN
file::fu
File::Fu(3pm) User Contributed Perl Documentation File::Fu(3pm)NAME
File::Fu - file and directory objects
SYNOPSIS
The directory constructor:
use File::Fu;
my $dir = File::Fu->dir("bar");
print "$dir
"; # 'bar/'
my $file = $dir + 'bar.txt';
print "$file
"; # 'bar/bar.txt'
my $d2 = $dir % 'baz'; # 'barbaz/'
my $d3 = $dir / 'bat'; # 'bar/bat/'
my $file2 = $dir / 'bat' + 'foo.txt'; # 'bar/bat/foo.txt'
The file constructor:
my $file = File::Fu->file("foo");
$file->e and warn "$file exists";
$file->l and warn "$file is a link";
warn "file is in ", $file->dir;
ABOUT
This class provides the toplevel interface to File::Fu directory and file objects, with operator overloading which allows precise path
composition and support for most builtin methods, as well as creation of temporary files/directories, finding files, and more.
The interface and style are quite different than the perl builtins or File::Spec. The syntax is concise. Errors are thrown with croak(),
so you never need to check a return code.
Constructors
The actual objects are in the 'Dir' and 'File' sub-namespaces.
dir
my $dir = File::Fu->dir($path);
See "new" in File::Fu::Dir
file
my $file = File::Fu->file($path);
See "new" in File::Fu::File
Class Constants
tmp
Your system's '/tmp/' directory (or equivalent of that.)
my $dir = File::Fu->tmp;
home
User's $HOME directory.
my $dir = File::Fu->home;
program_name
The absolute name of your program. This will be relative from the time File::Fu was loaded. It dies if the name is '-e'.
my $prog = File::Fu->program_name;
If File::Fu was loaded after a chdir and the $0 was relative, calling program_name() throws an error. (Unless you set $0 correctly before
requiring File::Fu.)
program_dir
Returns what typically corresponds to program_name()->dirname, but just the compile-time cwd() when $0 is -e/-E.
my $dir = File::Fu->program_dir;
Class Methods
THIS_FILE
A nicer way to say __FILE__.
my $file = File::Fu->THIS_FILE;
cwd
The current working directory.
my $dir = File::Fu->cwd;
which
Returns File::Fu::File objects of ordered candidates for $name found in the path.
my @prog = File::Fu->which($name) or die "cannot find $name";
If called in scalar context, returns a single File::Fu::File object or throws an error if no candidates were found.
my $prog = File::Fu->which($name);
Temporary Directories and Files
These class methods call the corresponding File::Fu::Dir methods on the value of tmp(). That is, you get a temporary file/dir in the
'/tmp/' directory.
temp_dir
my $dir = File::Fu->temp_dir;
temp_file
my $handle = File::Fu->temp_file;
Subclassing
You may wish to subclass File:Fu and override the dir_class() and/or file_class() class methods to point to your own Dir/File subclasses.
my $class = 'My::FileFu';
my $dir = $class->dir("foo");
See File::Fu::File and File::Fu::Dir for more info.
See Also
File::Fu::why if I need to explain my motivations.
Path::Class, from which many an idea was taken.
File::stat, IO::File, File::Spec, File::Find, File::Temp, File::Path, File::Basename, perlfunc, perlopentut.
AUTHOR
Eric Wilhelm @ <ewilhelm at cpan dot org>
http://scratchcomputing.com/
BUGS
If you found this module on CPAN, please report any bugs or feature requests through the web interface at <http://rt.cpan.org>. I will be
notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
COPYRIGHT
Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.
NO WARRANTY
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In
case of loss, no person or entity owes you anything whatsoever. You have been warned.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-05-13 File::Fu(3pm)