-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcheckFileExistorNot.sh
56 lines (39 loc) · 1.1 KB
/
checkFileExistorNot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
checkFileExistorNot()
{
# Parameters defined
InputPath=$1
InputFilename=$2
# Checking the parameters entered from user or not
if [ -z ${InputPath} ]
then
echo "Fail : Path : $InputPath : Parameter is not defined "
else
echo "Success : Path : $InputPath : Parameter is defined"
fi
if [ -z ${InputFilename} ]
then
echo "Fail : Path : $InputFilename : Parameter is not defined "
else
echo "Success : Path : $InputFilename : Parameter is defined"
fi
[ -d $InputPath ] > /dev/null
statuschk=$?
if [ $statuschk -eq 0 ]
then
echo "Checking started ....."
# Checking the file exist at path or not
[ -f $InputPath/$InputFilename ] > /dev/null
status=$?
if [ $status -eq 0 ]
then
echo "Success : File : $InputFilename exist at following path : $InputPath"
else
echo "Fail : File : $InputFilename does not exist at following path : $InputPath"
fi
else
echo "Entered path : $InputPath does not exist, please enter valid path"
fi
}
# Calling function
checkFileExistorNot '@your_path' '@your_file_name'