Home > Software design >  bash how to check if file was updated by hours?
bash how to check if file was updated by hours?

Time:03-21

so I am using this code:

   if [ $(find $@ -mtime  2 -print) ]; then
                    rm $@
                fi

To delete any file that was not updated for 2 days. I Will like to change it to hours, so it can be for example 5hr. How can this be done?

Thank you :)

CodePudding user response:

See here: find -mtime files older than 1 hour

find $@ -mmin  300 -print

should be the snipped you are looking for. Just replace your inner find with this. I would recommend just printing it first though, so you see if it gives you the intended result.

  •  Tags:  
  • bash
  • Related