How to test whether the files are existed or not
How to test whether the files are existed or not in particular folder from required list. If any file missed need to send mail with list of files missed and suspend the process some time
Thanks in advance
Suresh
[B]Question asked by visitor suresh[/b]
Re: How to test whether the files are existed or not
Hi Suresh ,
Whenever we will create a file using Cat Coommand,or ed command,or Vi file name...............
We check whether it is create successfully or not using the command
[B]echo $?[/B]
if returns 0 then it create successfully
if returns non zero value not create .....
Regards
Jahid
Re: How to test whether the files are existed or not
The filename is written in place of "?".
echo $?
Can you please give us some example.
Re: How to test whether the files are existed or not
-s will checks for the presence of the file.
if [ -s $file ]; then
#file found
else
#file not found
fi
The variable $file should have the file name with location as /user/barbie/sample.txt.
Re: How to test whether the files are existed or not
[FONT="Arial"]Dear Rpgubba,
Q. As u told [B]echo $?[/B] ,If u want to write a filename instead of "?"
That means u write like [B]echo $filename[/B]
It is not an error but it is take as a variable not a take filename.
For instance
[B]echo $filename hello how ru[/B]
the o/p is [B]hello how ru[/B][FONT="Arial"][/FONT][/FONT]
Re: How to test whether the files are existed or not
I thnk the command goes like this
#echo $filename
where filename is the one which u want to search for???
regards
Prakash