bash - Test file existence with exit status from gnu-find -


when test -e file not flexible enough, tend use following bash idiom check existence of file:

if [ -n "$(find ${find_args} -print -quit)" ] ;    echo "pass" else    echo "fail" fi 

but since interested in boolean value, there ${find_args} let me instead:

if find ${find_args} ; ... 

i'd no. man find...

find exits status 0 if files processed successfully, greater 0 if errors occur. deliberately broad description, if return value non-zero, should not rely on correctness of results of find.

testing output fine find. isn't "bash idiom". if that's not enough , have bash available can use extglobs , possibly globstar file matching tests [[. find should used complex recursive file matching, or actual searching files, , other things can't done bash features.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -