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:
Mac: How to setup email account in Apple Mail
How to import mysql innodb with foreign key constraint error?
How to find your MAC address in Mac and Window
How to split large file into several smaller files - Linux
How to sort drop down - Admin Generator - Symfony 1.4
Mac: Change print screen file format to jpg
How to open password protected zip in Mac OS X
WordPress Custom Taxonomy Pagination show 404 page not found error
Share this with your friends:-