Page 1 of 1

How to Check whether directory exists using shell script

Posted: Sat Jan 21, 2017 4:16 am
by chris ben
How to Check whether directory exists using shell script

Re: How to Check whether directory exists using shell script

Posted: Sat Jan 21, 2017 4:21 am
by Martin
dir=cache

if [ -d "$dir" ]; then
echo "$dir directory exist on the server"
fi
======================

OR

#!/bin/bash

if [ -d ~/directoryname]
then
echo "directory exists"


------------------------------
Martin N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree