Just wrote a script in bash shell that need to check if directory exists, else create the directory. I always need to write script that check the if a directory exists but i always forget :p. So i think it’s better for me to put this down for my later reference 🙂
To check if directory exists in bash shell script, check the command below:-
Advertisements
- The bash script below will check if directory exists:-
if [ -d /home/techie/backup/2010 ] then # do something here if exists fi
- The bash script below will check if directory is NOT exists:-
if [ ! -d /home/techie/backup/2010 ] then # if not exists do something here fi
Related posts:
How to join hjsplit file in Mac OS X
How to disable spotlight index for specific folder in Mac OS X?
How to change default save location for print screen in Mac OS X
Mac: how to disable print screen window shadow
How to merge .001 files in Mac OS X
How to batch resize image in Mac OS X
How to import contacts from Mac to Nokia N900
Debian: "There is no public key available for the following key IDs"
Share this with your friends:-