How to check if find command didn't find anything?

后端 未结 6 430
抹茶落季
抹茶落季 2021-01-01 14:11

I know that is possible to use for loop with find command like that

for i in `find $something`; do (...) done

but I want to use find comma

6条回答
  •  抹茶落季
    2021-01-01 14:48

    This worked for me

    if test $(find . -name "pattern" | wc -c) -eq 0
    then
        echo "missing file with name pattern"
    fi
    

提交回复
热议问题