In shell scripting how to find 14 days older than files and directory in a account

I need to list them with their memory space


0 ./.vxz.tmp
658 ./.zshrc
6 ./dummy.txt
2.1K ./ss1s:
489K ./sss.txt
154K ./ced.txt
406 ./test.csv
  • 2
    Please don't use Urgent Help!!! etc in the title - it doesn't work :-) – garethTheRed Mar 31 '15 at 6:36

To find files in the current directory that are more than 14 days old and list their sizes (in kilobytes) and their names, use:

find . -maxdepth 1 -mtime +14  -printf '%k %p\n'

How it works

  • find .

    Start looking for files in the current directory.

  • -maxdepth 1

    Look only in the current directory rather than recursively looking into subdirectories.

  • -mtime +14

    Look for files that are more than 14 days old.

    Note that, because of the way that find rounds off days to an integer, "more than 14 days" means at least 15 days. See man find for details on how find does the round-off.

  • -printf '%k %p\n'

    For each file found, print the size in kB and the name.


If you want to look only for regular files (no directory, block devices, etc.), then add -type f as follows:

find . -maxdepth 1 -type f -mtime +14  -printf '%k %p\n'
| improve this answer | |

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.