####This script starts here ####
###This script cheks if the a file exist current Directory ##
## script will propmt for filename ##
#!bin/ksh
echo "eneter Filename :"
read DUMPFILE;
echo " **** checking if the File exists **** "
if [ -e ${DUMPFILE} ];
then
echo " **** Given file exists in directory `pwd` ****"
else
echo " **** ERRR : Given file does not exist in directory `pwd` ****"
fi
Lets see how to use this code :
atoorpu@Linux01:[~/scripts] $ ls -al testfile
ls: testfile: No such file or directory
atoorpu@Linux01:[~/scripts] $ . check_file.sh
eneter Filename :
testfile
**** checking if the File exists ****
**** ERRR : Given file does not exist in directory /home/atoorpu/scripts ****
atoorpu@Linux01:[~/scripts] $ touch testfile
atoorpu@Linux01:[~/scripts] $ ls -al testfile
-rw-rw-r-- 1 atoorpu atoorpu 0 Oct 23 14:03 testfile
atoorpu@Linux01:[~/scripts] $ . check_file.sh
eneter Filename :
testfile
**** checking if the File exists ****
**** Given file exists in directory /home/atoorpu/scripts ****
atoorpu@Linux01:[~/scripts] $
atoorpu@Linux01:[~/scripts] $
No comments:
Post a Comment