How to Check whether directory exists using shell script

Discussions related with hosting control panels used, which include cPanel, Plesk, Directadmin etc..

Moderator: Staff

Post Reply
chris ben
Posts: 0
Joined: Fri Sep 16, 2016 10:09 am

How to Check whether directory exists using shell script

Post by chris ben »

How to Check whether directory exists using shell script


Martin
Posts: 36
Joined: Fri Sep 16, 2016 10:34 am

Re: How to Check whether directory exists using shell script

Post 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


If you are looking for assistance in server management, please get in touch with our support.
Post Reply