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:-
1234if [ -d /home/techie/backup/2010 ]then# do something here if existsfi - The bash script below will check if directory is NOT exists:-
1234if [ ! -d /home/techie/backup/2010 ]then# if not exists do something herefi
Related posts:
How to verify SHA-1 checksum in Mac OS X?
How to install Fedora to USB drive
How to create shortcut in Mac OS X
How to add Primary and Secondary DNS server - /etc/resolve.conf - Linux
Macport: Can't map the URL 'file://.' to a port description file
How to split compressed file into smaller files in Linux / Mac
How to set SVN_EDITOR environment variable
How to install flash player in Ubuntu
Share this with your friends:-