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:
WordPress: How to open rss links in new window?
How to print screen in Asus Zenfone 6
SVN: How to commit only modified files via command line
How to disable notification center in Mac OS X
Speed Up and Save Your Website Bandwidth with GZip Compression
How to enable personal file sharing in Ubuntu 10.04
How to enable file sharing in Mac OS X?
How to resize image in Mac OS X
Share this with your friends:-