Created
August 13, 2013 19:04
-
-
Save phx/6224550 to your computer and use it in GitHub Desktop.
check to see if file/directory exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !#/bin/bash | |
| if [ ! -f /tmp/foo.txt ]; then | |
| echo "File not found!" | |
| fi | |
| # for directories: | |
| if [ -d "$DIRECTORY" ]; then | |
| # Control will enter here if $DIRECTORY exists. | |
| fi | |
| # for symlinked directories | |
| if [ -d "$LINK_OR_DIR" ]; then | |
| if [ -L "$LINK_OR_DIR" ]; then | |
| # It is a symlink! | |
| # Symbolic link specific commands go here. | |
| rm "$LINK_OR_DIR" | |
| else | |
| # It's a directory! | |
| # Directory command goes here. | |
| rmdir "$LINK_OR_DIR" | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment