From 5d33f5877eb0e3ed8ed88cac758a23ec5c4f1a8d Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 19 Sep 2018 16:45:37 -0600 Subject: [PATCH] Created checkExist function for files and directories --- backup.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/backup.sh b/backup.sh index a03ea85..36b3c77 100755 --- a/backup.sh +++ b/backup.sh @@ -39,6 +39,36 @@ function quit { fi } +function checkExist { + if [ "$1" = "ff" ]; then + # find file + if [ -e "$2" ]; then + # found + echo -e "${normal}${stamp} File found: ${yellow}${2}${normal}" \ + >> $logFileVerbose + return 0 + else + # not found + echo -e "${red}${stamp} File NOT found: ${yellow}${2}${normal}" \ + >> $logFileVerbose + return 1 + fi + elif [ "$1" = "fd" ]; then + # find directory + if [ -d "$2" ]; then + # found + echo -e "${normal}${stamp} Dir found: ${yellow}${2}${normal}" \ + >> $logFileVerbose + return 0 + else + # not found + echo -e "${red}${stamp} Dir NOT found: ${yellow}${2}${normal}" \ + >> $logFileVerbose + return 1 + fi + fi +} + ### End of Functions ###