Check the at least one file exists in the directory
Below code is doing file validation properly but returning error after completion second loop. error "file does not existing". my requirement is to check only once if the file exists then it should delete data from table and enter in to the second do loop and print the file names then exit without any error. if there is no single file exists in the directory then should give error.
abc_234.dat abc _123.dat
Last edited by Peasant; 10-10-2019 at 12:31 AM..
Reason: Code tags, use them.
Hi,
I need to prompt for a response from a user to enter a path
read dest_dir?"Please Enter Directory :"
How do I do this until a valid directory is entered by the user. I can use
to check the existence of the directory. However when I try the following I cannot get it to work.
while ... (2 Replies)
I'm trying to write a script that identifies whether a directory of the form AWL.????????.IP exists. I have one that exists which is AWL.05301032.IP.
When I test like this: If ]
I get true, but when I test like this:
If ]
Or like this
If ]
Or any other variation of wild cards, I... (4 Replies)
Hi.
I what to write a make file that inside a target I want to check if a directory exists.
some like:
### make
a:
if ;then
<command 1>
else
<command 2>
fi
### make end
Thanks a lot
---------------------- (2 Replies)
Hello:
Can someone please help me figure out what is wrong here, my script does not move on to the "else" part even though there is no .ssh directory on my remote server:
$more putkey.sh
#!/bin/ksh
for server in `cat list`
do
if ; then
cat $HOME/.ssh/id_rsa.pub |ssh $server ' cat >>... (4 Replies)
Hey guys im trying to check if the directory exists
i get a syntax error on the elif statement iv tried using else and still same result im not sure. If the directory does not exist can i just insert mkdir /tmp/old under the elif once that part gets working
if ; then
#do nothing
elif
echo... (20 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)
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,
I am using solaris 10 OS and bash shell.just checking for small code snippet which follows below.
/export/home/vomappservers/spa/common/5.0
/export/home/vomappservers/spa/common/scripts
/export/home/vomappservers/spa/tools
/export/home/vomappservers/spa/scm5.0/SCCS... (5 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)
Discussion started by: maris_markur
1 Replies
LEARN ABOUT SUSE
io::atomicfile
IO::AtomicFile(3) User Contributed Perl Documentation IO::AtomicFile(3)NAME
IO::AtomicFile - write a file which is updated atomically
SYNOPSIS
use IO::AtomicFile;
### Write a temp file, and have it install itself when closed:
my $FH = IO::AtomicFile->open("bar.dat", "w");
print $FH "Hello!
";
$FH->close || die "couldn't install atomic file: $!";
### Write a temp file, but delete it before it gets installed:
my $FH = IO::AtomicFile->open("bar.dat", "w");
print $FH "Hello!
";
$FH->delete;
### Write a temp file, but neither install it nor delete it:
my $FH = IO::AtomicFile->open("bar.dat", "w");
print $FH "Hello!
";
$FH->detach;
DESCRIPTION
This module is intended for people who need to update files reliably in the face of unexpected program termination.
For example, you generally don't want to be halfway in the middle of writing /etc/passwd and have your program terminate! Even the act of
writing a single scalar to a filehandle is not atomic.
But this module gives you true atomic updates, via rename(). When you open a file /foo/bar.dat via this module, you are actually opening a
temporary file /foo/bar.dat..TMP, and writing your output there. The act of closing this file (either explicitly via close(), or
implicitly via the destruction of the object) will cause rename() to be called... therefore, from the point of view of the outside world,
the file's contents are updated in a single time quantum.
To ensure that problems do not go undetected, the "close" method done by the destructor will raise a fatal exception if the rename() fails.
The explicit close() just returns undef.
You can also decide at any point to trash the file you've been building.
AUTHOR
Primary Maintainer
David F. Skoll (dfs@roaringpenguin.com).
Original Author
Eryq (eryq@zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com).
REVISION
$Revision: 1.2 $
perl v5.12.1 2005-02-10 IO::AtomicFile(3)