I do not remember where I saved pdf and text files under Linux. I have downloaded files from the Internet a few months ago. How do I find my pdf or text files?

You need to use the find command. Each file has three time stamps, which record the last time that certain operations were performed on the file:

[a] access (read the file’s contents) – atime

[b] change the status (modify the file or its attributes) – ctime

[c] modify (change the file’s contents) – mtime

You can search for files whose time stamps are within a certain age range, or compare them to other time stamps.

You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.

  • -mtime +60 means you are looking for a file modified 60 days ago.
  • -mtime -60 means less than 60 days.
  • -mtime 60 If you skip + or – it means exactly 60 days.

So to find text files that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -print

Display content of file on screen that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -exec cat {} \;

Count total number of files using wc command
$ find /home/you -iname "*.txt" -mtime -60 | wc -l

You can also use access time to find out pdf files. Following command will print the list of all pdf file that were accessed in last 60 days:
$ find /home/you -iname "*.pdf" -atime -60 -type -f

List all mp3s that were accessed exactly 10 days ago:
$ find /home/you -iname "*.mp3" -atime 10 -type -f

There is also an option called -daystart. It measure times from the beginning of today rather than from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday, type the command
$ find /home/you -iname "*.mp3" -daystart -type f -mtime 1


  • -type f – Only search for files and not directories

-daystart option

The -daystart option is used to measure time from the beginning of the current day instead of 24 hours ago. Find out all perl (*.pl) file modified yesterday, enter:

find /nas/projects/mgmt/scripts/perl -mtime 1 -daystart -iname "*.pl"

You can also list perl files that were modified 8-10 days ago, enter:
To list all of the files in your home directory tree that were modified from two to four days ago, type:

find /nas/projects/mgmt/scripts/perl -mtime 8 -mtime -10 -daystart -iname "*.pl"

-newer option

To find files in the /nas/images directory tree that are newer than the file /tmp/foo file, enter:

find /etc -newer /tmp/foo

You can use the touch command to set date timestamp you would like to search for, and then use -newer option as follows

touch --date "2010-01-05" /tmp/foo
# Find files newer than 2010/Jan/05, in /data/images
find /data/images -newer /tmp/foo

Read the man page of find command for more information:
man find

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 53 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
53 comments… add one
  • Alankar Jan 29, 2009 @ 17:30

    Suppose I want to remove a set of file frm date say 1st Jan 2009 – 20 Jan 2009 in a specific Directory.
    Let me know

  • sowmya Apr 29, 2009 @ 10:59

    How to create a directory called Red and under that Red directory i want to create a file called Hat. How please guide me as soon as possible

    • Anonymous Jun 14, 2010 @ 5:14

      Please use the following command :

      mkdir Red

      cd Red

      Red/>mkdir Hat

      cd Hat


      Please let me know if this is clear



      • Amol Apr 8, 2011 @ 5:56

        mkdir Red
        cd Red
        touch Hat

      • Taylor Dec 1, 2011 @ 18:50

        mkdir -p Red/Hat

    • R Duke Jul 4, 2010 @ 9:57

      @sowya: to create a file ./Red/Hat when the directory “Red” doesn’t exist yet, use mkdir and touch:

      mkdir Red
      touch Red/Hat

  • webdesign Jun 26, 2009 @ 8:21

    Thx for the find examples ! they were very helpfull

  • dkalaluhi Jul 24, 2009 @ 13:08

    Find examples were great…needed to use this to get a report on a shared drive…getting the output was a bit of a pain, until the resident guru came through:

    Finds files older than 18months and newer than 24 months, cat’s the output to a CSV in the format:
    /some/path/somewhere, size in bytes, Access Time, Modified Time

    find /dir/dir -type f -mtime +540 -mtime -720 -printf \”%p\”,\”%s\”,\”%AD\”,|”%TD\”\\n > /dir/dir/output.csv

    works nicely, and the mem usage wasn’t bad at all, need eclipse and birt though because of

  • Matabares Oct 5, 2009 @ 14:50

    In aix 5.3 put -name instead -iname

    • Dan Saint-Andre Apr 8, 2015 @ 21:44

      As I understand the ‘find’ command, “-name” searches for files with the name fragment as typed. In contrast, “-iname” looks for the name fragment and ignores any upper-lower case distinction. For example, “-iname framis” would find all variations of “framis”, “Framis”, “FRAMIS”, etc.

  • Masonite2009 Oct 14, 2009 @ 22:50

    I would like to display the date modified, the owner of the file, and the file size of the files that I have found using the find command. Is there a way to do that?

    • Bharadh Apr 18, 2012 @ 23:36

      Pipe the find output to xargs and get the listing with modification timestamp
      Example: find . -name foo | xargs ls -tl

  • mike Oct 16, 2009 @ 10:02

    the commands in the examples are not working for me, im trying to get the times a particular word file has been accessed on my computer in the last week so i tried to use the -atime example to see if it was accessed one day ago, i typed this into terminal:

    find /home/you -iname “*.mp3” -atime 01 -type -f

    it didnt work, can anyone help me?

    • Amol Apr 8, 2011 @ 6:01

      find / -name “*.mp3” -atime +01 -type f

      use this command , it will surely work

  • ABhik Feb 23, 2010 @ 20:28

    @Mike – Replace ” by ‘ and try.

  • Ken May 6, 2010 @ 1:07

    I’ve got this in my delicious bookmarks and use it often, thank you. For some reason on one of my computers I have to leave the word -print off the command or I get a message about paths must precede expression. Still…thank you for the page.

  • rduke15 Jun 6, 2010 @ 12:15

    If you need a specific date range many days ago, it would be boring to calculate how many days ago it was exactly. Here is an example looking for files modified between May 9 2008 and May 13 2008, in /home:

    touch –date “2008-05-09” /tmp/after
    touch –date “2008-05-13” /tmp/before
    find /home/ -type f -newer /tmp/after -not -newer /tmp/before

    • bhageerathan Apr 20, 2011 @ 11:18

      very helpful…:) thank you

    • Prashant Oct 17, 2011 @ 10:51

      good one

    • Pradip Oct 7, 2013 @ 23:11

      Very helpful and clean!

  • john Aug 19, 2010 @ 18:56

    -rw-rw-rw- 1 qmaster qmaster 294520 Aug 16 00:35 HSTD.191.807
    -rw-rw-rw- 1 qmaster qmaster 525118 Aug 17 00:56 HSTD.191.808
    -rw-rw-rw- 1 qmaster qmaster 698575 Aug 18 01:42 HSTD.191.809
    -rw-rw-rw- 1 qmaster qmaster 829239 Aug 19 01:25 HSTD.191.810

    I would like to copy to a directory one of the following files by using today’s date minus one. In other words when I execute my script I want yesterdays file.

    any help would be appreciated.

  • Nick Sep 18, 2010 @ 14:03

    This should do the trick –

    find . -type f -iname ‘HSTD*’ -daystart -mtime 1 -exec cp {} /path/to new/dir/ \;


  • Thabiso Dec 8, 2010 @ 10:18


    How do I list the files of only today’s date and dump them into some output file?

  • Michael Dec 31, 2010 @ 19:23

    I have a new Linux server. CentOS 5.5. I want to know if their is any way to see exactly what files are added or changed or updated after I install a program. How can I do this?

  • vara Jun 19, 2011 @ 9:40

    i want find the files created or modified in particular date

    • Esteban Jan 7, 2016 @ 9:25

      find /path/to/dir -newermt “date”
      find /path/to/dir -newermt “Feb 07”
      find /path/to/dir -newermt “yyyy-mm-dd”
      ## List all files modified on given date
      find /path/to/dir -newermt yyyy-mm-dd ! -newermt yyyy-mm-dd -ls
      ### print all *.pl ###
      find /path/to/dir -newermt “yyyy-mm-dd” -print -type f -iname “*.pl”

  • rana Jun 30, 2011 @ 7:05

    plz tell me command for following :-

    find all the files in current folder with modification time (modified in last 6 hrs and not modified in last 4hrs) with their name starting with k and they must be regular files and not directories finally delete them..

    • Jagan Oct 31, 2013 @ 9:20

      try below one..

      find . -type f -name “k*.*” -mmin -360 -exec ls -l ‘{}’ ; | xargs -0 /bin/rm -f

  • Ash Aug 19, 2011 @ 21:39

    How do i find a file based on the date input i give and move that file, a file with date before that and after that to a directory using find.
    For Example: I want to find a file “identity_*” last modified on 17th Aug moved to a directory along with one modified on 18th Aug, 19th Aug.

    Any inputs are highly appreciated

  • Evgeni Jan 20, 2012 @ 22:50

    If a file is moved to trash bin, is its ctime modified ?

  • Deepak Kumar Mar 20, 2012 @ 9:46

    very usefull commands thanks for it.

  • estani Apr 5, 2012 @ 9:32

    the -daystart option examples are wrong, daystart should be defined before the time constraint. From the man page:

    Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the
    beginning of today rather than from 24 hours ago. This option only affects
    tests which appear later on the command line.

    The previous example was ok though.

  • chandan Jun 28, 2012 @ 20:07

    tmpwatch is also good tool.

  • VirtualRon Sep 4, 2012 @ 21:31

    Just for fun. I have a large media server, and my kid is always asking if I have any new movies. So… I created a dir named “new”, and run the following script:

    find /media/Movies -type f -mtime -30 -exec ln -s {} /media/Movies/New/ \;

    so… she can just click in the “New” directory, and it shows all movies added in the past month. they’re links, so she can just click them to play, without having to browse categories.

  • mohan Mar 4, 2013 @ 14:25

    Actually i have modified the creation date and time of a linux file using ‘touch command’, now i need the original date and time back. Is there any command to retrieve the same.

  • Sandeep Mar 12, 2013 @ 11:51

    How to find files access in last 1 hour. pls share some script.

  • VirtualRon Mar 12, 2013 @ 18:02

    find / -mmin -60

  • GST Mar 28, 2013 @ 17:13


    I am currently using a script to shoot an email containing the list of all file names which are there on our FTP server for more than 30 minutes. Now I want to exclude one file which lands on the server around 21:00 ET and stays there till 03:00 AM ET, as it is scheduled to process at 3 AM ET. Thus, if I use the current script then it will shoot an email for it in those 6 hours also, which I dont want because it is irrelevant.

    Could you please help?


  • Pjack Jun 10, 2013 @ 2:49

    You have to add the daystart before mtime or no use.
    find /nas/projects/mgmt/scripts/perl -mtime 8 -mtime -10 -daystart -iname “*.pl” =>
    find /nas/projects/mgmt/scripts/perl -daystart -mtime 8 -mtime -10 -iname “*.pl”

  • Rahul Patil Jul 11, 2013 @ 11:42

    daystart and mtime sequence matter.

    find /nas/projects/mgmt/scripts/perl -mtime 1 -daystart -iname “*.pl”
    it should be as:
    find /nas/projects/mgmt/scripts/perl -daystart -mtime 1 -iname “*.pl”

  • Thinker Jul 13, 2013 @ 10:23

    rw-rw-rw- 1 qmaster qmaster 294520 Aug 16 00:35 HSTD.191.807
    -rw-rw-rw- 1 qmaster qmaster 525118 Aug 17 00:56 HSTD.191.808
    -rw-rw-rw- 1 qmaster qmaster 698575 Aug 18 01:42 HSTD.191.809
    -rw-rw-rw- 1 qmaster qmaster 829239 Aug 19 01:25 HSTD.191.810

    How to find all files created in a specific month using a variable in the current directory without drilling down in the sub directories. . Then moving these files to a sub directory.

  • Jagan Oct 31, 2013 @ 9:24


    i have 10 servers in which logs are created and after every 1 day logs are zipped..so what i need is i want the files which are not modified last 24 hours….i know the files which are modified last 24 hours but i want to know the files which are not modified in last 24 hours..Please help..thanks in advance..


  • James GOodman Apr 3, 2014 @ 22:09

    I want to identify files where the creation date is different from the modification date. Is there a way to do that using find?

  • Jokin Aug 9, 2014 @ 1:50

    If you have a couple of cofuginration files you need to edit to change a parameter. And you want to make sure you get them all.Then find is also very handy combined with xargsvi `find . -type f |xargs grep -l `

  • Betty Aug 9, 2014 @ 3:09

    I used above commands (with $sploitpattern), but it gave fliaed results I think. It reports 2 files:- one is MemcachedStore.php from package OpenID- one is module.audio.mp3.php from mediamanager plugin of TinymceNot sure which regex then.

  • araybold Dec 3, 2014 @ 12:12

    Your explanation of mtime contains multiple contradictions over how to specify files that were modified ‘(on or) before n days ago’, ‘(on or) after n days ago’ and ‘exactly 60 days ago’.

  • Lucas Dec 10, 2014 @ 10:32


    How would you check the last time a file has been transferred to another device (e.g a memory stick)

    Many thanks,

  • Dan Saint-Andre Apr 8, 2015 @ 21:41

    It seems that your code-fragment for “8-10” days appears in place of the fragment for “two to four days”. Also, there is no example fragment for “two to four days”

  • Mauro Aug 26, 2015 @ 21:38

    hello how do find the file created or modified on friday?
    I have to do a search based on the name of the day

  • nilesh Jan 28, 2016 @ 20:07

    I am doing FTP to remote server. I wanted to transfer only those file which are created today. could you please help and provide some script

  • kozaki Apr 23, 2016 @ 9:59

    I see three typos; correct them unless I was wrong.

    —You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago.
    +++You can use -mtime option. It returns list of file if the file was last modified N*24 hours ago.

    $ find /home/you -iname “*.pdf” -atime -60 -type -f
    $ find /home/you -iname “*.pdf” -atime -60 -type f


    —$ find /home/you -iname “*.mp3” -atime 10 -type -f
    +++$ find /home/you -iname “*.mp3” -atime 10 -type f

  • Rizwan Aug 24, 2016 @ 1:49

    Hi I would like to list out files and directories on 23/7/2013. How can I get it pls share the command

  • Aswani Jun 13, 2017 @ 9:58

    Could anyone please share a Unix command to check a file which was generated for current day from 00:00 hours

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum