Skip to content

Instantly share code, notes, and snippets.

@liuyix
Last active December 22, 2015 03:18
Show Gist options
  • Select an option

  • Save liuyix/6408973 to your computer and use it in GitHub Desktop.

Select an option

Save liuyix/6408973 to your computer and use it in GitHub Desktop.
shell snippet detect file exists by regexp
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