I am working on a purging logic where i need to delete the logs older than 7 days.
Now the logs are of two types : 1) begins with developer_ and 2) ends with _c
The logs I am concerned about are only after /NAS/logs
and not after any other subfolders in this path.
below are logs sample:
/NAS/logs/.snapshot/Enterprise_Primary.2019-11-17_1300/developer_score_20191113.log
/NAS/logs/.snapshot/Enterprise_Primary.2019-11-17_1300/trdcvf_03_00_c.log.20191113163858
/NAS/logs/trddffgc004_00_c.log.20191118030038
/NAS/logs/developer_run_score.log.20191118030039
Here I want to exclude all the logs which are in the hidden folder .snapshot as i dont have access on those.
I am trying to identify them using below command but it keeps giving me the .snapshot files as well.
I also tried -prune option but no help.
find /NAS/logs/ -mindepth 1 -type f \( -iname "*_c.log.*" -or -iname "developer_run_*" \) -not -path "./.snapshot/*"
Final command
find /NAS/logs/ -mindepth 1 -type f \( -iname "*_c.log.*" -or -iname "developer_run_*" \) -not -path "./.snapshot/*"-mtime +7 -delete
Can anyone please help me to exclude that directory from the find?
_c
". Did you mean "contains_c
" perhaps? But even then you have no files matching criterion 1 and criterion 2. Perhaps that was also intended to be or?-D tree
debug option.