-1

Basically, we want to find all files that are more than a year old for archiving purposes.. we have a specific drive dedicated for data storage. Inside those are sub-directories which contains other sub-directories as well. What we want is a command that we can run to list all those files with the following details:

  • Date last modified
  • Owner
  • File Size in Human Readable format
  • The filename and its file path

Kind of like an output like this:

Demouser 11G /datadrive/January/dataset1
Demouser 10G /datadrive/January/dataset2
Demouser 9G /datadrive/January/dataset1
Demouser 8G /datadrive/February/dataset3
Demouser 7G /datadrive/January/dataset3

What we have no is somewhat similar to the output above, although it is sorted per directory, and what we want is to sort it irregardless of the location and also only files that are more than a year old.

Guthrie
  • 13
  • 3
  • 2
    And what is your problem/question with this? At this time, it sounds like you want someone else to write this script for you. – BulletBob Jan 28 '20 at 07:39
  • Use du and https://unix.stackexchange.com/questions/194863/delete-files-older-than-x-days – Panki Jan 28 '20 at 07:48

1 Answers1

3

You can use the find command on GNU/Linux systems like this:

find . -mtime +365 -printf "%-20f %-10s %P\n"

-mtime +365 selects files older than one year (over 366 days old). You can modify the -printf argument to whatever you want to print.