Last active
December 22, 2015 03:18
-
-
Save liuyix/6408973 to your computer and use it in GitHub Desktop.
shell snippet detect file exists by regexp
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
| function exist() { | |
| if [ ! -z $1 ];then | |
| if ls $1 &>/dev/null;then | |
| echo 0 | |
| return 0 | |
| fi | |
| fi | |
| echo 1 | |
| return 1 | |
| } | |
| if [ $(exist "$1") == 0 ];then | |
| echo "$1 exist!" | |
| else | |
| echo "$1 not exists!" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment