Home > Mobile >  log deleted files in linux
log deleted files in linux

Time:06-24

I am using the following command to delete the files that are older than 10 days, but I also want to store(log) the list of files that are being deleted using the below command.

find ./path/delete -type f -name '*' -mtime  10 -exec rm {} \; 

CodePudding user response:

If you create a file to log to (touch ./path/to/logfile), just add another -exec to your command. Below is a very basic example, but you can add to it:

find ./path/delete -type f -name '*' -mtime  10 -exec rm {} \; -exec echo {} >> ./path/to/logfile \;
  • Related