Thursday, November 5, 2015

Shell script - Check if the files exists in a file


This is a simple script to look for a file in a given location.



















#!/usr/bin/ksh
 
echo " File name please : "
read FILENAME;
dataDir=/u01/app/oracle/dpump; ### Directory to look for a file ###
sourceFile=SCOTT.dmp; ### file name to search for ###
 
cd /u01/app/oracle/dpump;
echo " Present directory : " `pwd`"";
 
##Did we get a file?
 
if [ -e ${dataDir}/${sourceFile} ];
then
echo "Found file !! "

else
echo " No file found !!! "

fi

No comments:

Post a Comment