-
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
Question asked by visitor suresh
-
Junior Member
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
echo $?
if returns 0 then it create successfully
if returns non zero value not create .....
Regards
Jahid
-
Junior Member
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.
-
Expert Member
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.
-
Junior Member
Re: How to test whether the files are existed or not
Dear Rpgubba,
Q. As u told echo $? ,If u want to write a filename instead of "?"
That means u write like echo $filename
It is not an error but it is take as a variable not a take filename.
For instance
echo $filename hello how ru
the o/p is hello how ru
-
Contributing Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules