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.
BASE_PATH=/data/jobs/runs
env=test
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?
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:
#!/bin/bash
BASE_PATH=/data/jobs/runs
env=test
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.