linux - Search Multiple directories and return one result -


i'm trying bring piece of code had running on aix box on linux , can't work.

[ -f $folderpath/*/filename.txt ] && echo 1 || echo 0 

the above searchs folderpath , * subdirectories looking filename.txt. if found (more once), returns 1, otherwise returns 0.

in linux, many arguments error, thought changing [[ ]] fix this, doesn't seem handle wildcard * in that.

anyone ideas?

thanks

you try following command , query status code $?:

find $folderpath -name 'filename.txt' | grep -e '*' 

this returns 1 when there no files listed find command , 0 when there are.

optionally, if you're interested in hitting specific level avoid deep searches down directory tree can use -maxdepth n option.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -