2008-01-16-how-to-find-files-in-linux.md 509 Bytes
Newer Older
Danesh Manoharan's avatar
Danesh Manoharan committed
1
2
---
title: How to find files in linux
3
author: Danesh Manoharan
Danesh Manoharan's avatar
Danesh Manoharan committed
4
5
6
7
8
9
10
date: 2008-01-15T20:23:25+00:00
pvc_views:
  - 12233
dsq_thread_id:
  - 896237097

---
11
Need to find files older than certain time frame? This will help, "find [dir] -type f -mtime +[24hours*n] "
Danesh Manoharan's avatar
Danesh Manoharan committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Examples,

Show files older than 7 days

    find /tmp/ -type f -mtime +7

Show files older than 7 days and rm them.

    find /tmp/ -type f -mtime +7 -exec rm {} \;

or if you have a large number of files

    find /tmp/ -type f -mtime +7 | xargs rm