0

I have a set of configuration backups that are organized like

backup/site1/10-11-2019
backup/site1/11-11-2019
backup/site1/12-11-2019

backup/site2/10-11-2019
backup/site2/11-11-2019
backup/site2/12-11-2019

backup/site3/10-11-2019
backup/site3/11-11-2019
backup/site3/12-11-2019

I need to list the configuration files that are less than specific size for one particular date for all sites. In a way so that I could combine following two commands from backup directory

find . -type d -name "11-11-2019"
find . -name "*.cfg" -size +500c

Please help me combining these two commands

0

You can use -path instead of -name:

find . -type f -path '*/11-11-2019/*.cfg' -size +500c
|improve this answer|||||
  • very nice suggestion but for some reason it's not returning anything tried both find . -type f -path '*/11-11-2019/*.cfg' -size -50c find . -type f -path '*/11-11-2019/*' -size -50c – Prem Nov 12 '19 at 7:35
  • you're missing the * before and after the directory. – pLumo Nov 12 '19 at 7:37
  • This one works find . \( -type f -and -path '*/2019-11-11/*' \) -name "*.cfg" -size -50c -print – Prem Nov 12 '19 at 7:37
  • it is automatically replacing * in my comment – Prem Nov 12 '19 at 7:38
  • not sure why ( ) is needed – Prem Nov 12 '19 at 7:41
-1
find . -type d -name "11-11-2019" -a -name "*.cfg" -size +500c

-a stands for AND condition

|improve this answer|||||
  • 1
    this won't find anything as *.cfg is not of type d and name cannot be both 11-11-2019 and *.cfg – pLumo Nov 12 '19 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.