Using find to delete in multiple directories with one command

I wanted to list out all the subfolder under the path ${BASE_PATH}/*/${env}/{state1,state2,state3,state4}/*_BNDL/{log,state} (under this datetime stamp folder will be present) and wanted to delete automated way.

find ${BASE_PATH}/*/${env}/{state1,state2,state3,state4}/*_BNDL/{log,state} -mindepth 1 -maxdepth 1 -type d -ctime +15

But on PyCharm I am getting this warning

In POSIX sh, brace expansion is undefined. See SC2039, I am able to run the command on the shell and it works fine but why this warning?

enter image description here

Asked By: srinivas


You need to let your IDE know which shell is going to be used to run your code. The best way to do this is to add the appropriate shebang:

find "${BASE_PATH}"/*/"${env}"/{state1,state2,state3,state4}/*_BNDL/{log,state} -mindepth 1 -maxdepth 1 -type d -ctime +15

You can also use a shell directive instead, but this isn’t appropriate here.

Answered By: Stephen Kitt
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.