say i would like to check if the file is existed before i use rm command. How can i do it?
i know if i can use find, but i would like to have a good interface (in a shell script)
thks (3 Replies)
We recieve some logs on our windows box via FTP on a daily basis, in the same directory. I would like to check for missing logs files and add their name to a text file.
Something like...
Check if C:\logs\file1_currentdate exists (if not, add file1_currentdate to... (1 Reply)
There are many servers and their directory structer should be exactly the same. To check the directory path for all servers, I wrote a script.
#! /bin/ksh
ARRAY_DIRECTORIES="/c/dev/custom/bin"
ARRAY_DIRECTORIES="/c/dev/db/custom/src"
ARRAY_ENV="remoteName200"
ARRAY_ENV="remoteName201"... (2 Replies)
I have the below script to check whether directory is exist or not , now I sure the directory /abc NOT exist , but when run the script , it still pop the result is "the directory exist" , could suggest what is wrong ? thx
ll -d /abc > /dev/null 2>&1
if
then
echo "the directory exist !!"
... (7 Replies)
Hi
Does anybody know how I can check if a file exists
i.e. see bellow, this doesn't work by the way and if tried countless variations on this
file1=$one/file111.txt
if
then
echo "Present"
else
echo "Not present"
fi
result :
Not present
(file is already present, eventhough its... (3 Replies)
Hi,
I am trying to create a bash script which will check if file exist then remove that file else do nothing. I have to do same process for three files in same script. I have written code for one file and trying to run it.
if
then
rm -r /user1/abc/File1
fi
When I run this code it... (1 Reply)
Hi,
I created following script to check if file exist:
#!/bin/bash
SrcDir=$1
SrcFileName=$2
SrcTimePeriod=$3
if ;then
echo 1
else
echo 0
fi
I ran it like: /apps/Scripts/FileExist.sh /apps/Inbox file1 2nd_period_2010
Even file exist at that location, my above command is... (4 Replies)
HI folks,
can any one tell me how to check whether the file is existed in a directory or not .
let me tell you my requirement : if the file is existed i should display a one message or else i have to send a mail ..
i have the mail logic .. but I'm failed to check file existence .. please... (5 Replies)
Discussion started by: sravan008
5 Replies
LEARN ABOUT DEBIAN
io::async::file
IO::Async::File(3pm) User Contributed Perl Documentation IO::Async::File(3pm)NAME
"IO::Async::File" - watch a file for changes
SYNOPSIS
use IO::Async::File;
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my $file = IO::Async::File->new(
filename => "config.ini",
on_mtime_changed => sub {
my ( $self ) = @_;
print STDERR "Config file has changed
";
reload_config( $self->handle );
}
);
$loop->add( $file );
$loop->run;
DESCRIPTION
This subclass of IO::Async::Notifier watches an open filehandle or named filesystem entity for changes in its "stat()" fields. It invokes
various events when the values of these fields change. It is most often used to watch a file for size changes; for this task see also
IO::Async::FileStream.
While called "File", it is not required that the watched filehandle be a regular file. It is possible to watch anything that stat(2) may be
called on, such as directories or other filesystem entities.
EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters.
on_dev_changed $new_dev, $old_dev
on_ino_changed $new_ino, $old_ino
...
on_ctime_changed $new_ctime, $old_ctime
Invoked when each of the individual "stat()" fields have changed. All the "stat()" fields are supported apart from "blocks" and "blksize".
Each is passed the new and old values of the field.
on_devino_changed $new_stat, $old_stat
Invoked when either of the "dev" or "ino" fields have changed. It is passed two File::stat instances containing the complete old and new
"stat()" fields. This can be used to observe when a named file is renamed; it will not be observed to happen on opened filehandles.
on_stat_changed $new_stat, $old_stat
Invoked when any of the "stat()" fields have changed. It is passed two File::stat instances containing the old and new "stat()" fields.
PARAMETERS
The following named parameters may be passed to "new" or "configure".
handle => IO
The opened filehandle to watch for "stat()" changes if "filename" is not supplied.
filename => STRING
Optional. If supplied, watches the named file rather than the filehandle given in "handle". The file will be opened for reading and
then watched for renames. If the file is renamed, the new filename is opened and tracked similarly after closing the previous file.
interval => NUM
Optional. The interval in seconds to poll the filehandle using stat(2) looking for size changes. A default of 2 seconds will be
applied if not defined.
METHODS
$handle = $file->handle
Returns the filehandle currently associated with the instance; either the one passed to the "handle" parameter, or opened from the
"filename" parameter.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
perl v5.14.2 2012-10-24 IO::Async::File(3pm)