check file/dir exists
This commit is contained in:
parent
51c5b24871
commit
0b0c69b261
21
snipplets/code/Bash/file_folder_exists.sh
Normal file
21
snipplets/code/Bash/file_folder_exists.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check file exists
|
||||
FILE=/etc/resolv.conf
|
||||
|
||||
if [ -f "$FILE" ]; then
|
||||
echo "$FILE exists."
|
||||
else
|
||||
echo "$FILE does not exist."
|
||||
fi
|
||||
|
||||
[ -f /etc/resolv.conf ] && echo "/etc/resolv.conf exists."
|
||||
|
||||
# Check directory exists
|
||||
DIR=/etc/docker
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
echo "$DIR is a directory."
|
||||
fi
|
||||
|
||||
[ -d /etc/docker ] && echo "/etc/docker is a directory."
|
Loading…
Reference in New Issue
Block a user