Results 1 to 5 of 5

Thread: simple mtime issue

  1. #1
    Join Date
    May 2009
    Location
    Bradford UK
    Beans
    45
    Distro
    Ubuntu 10.04 Lucid Lynx

    simple mtime issue

    hey guys, having a weird issue using mtime with find

    Code:
    find . -name '*.*' -mtime -14 -exec ls -l {} \;
    wanting to get everything thats 15 days old and less to current date, ive used this before and it works but im not sure if im just doing something wrong this time.

    below is sample output
    $ find . -name '*.*' -mtime -14 -exec ls -l {} \;
    -rw-r--r-- 1 2001 sites 168106 2009-08-13 10:03 128847_1.jpg
    -rw-r--r-- 1 2001 sites 181097 2009-08-13 10:03 128847_2.jpg
    -rw-r--r-- 1 2001 sites 131183 2009-08-13 10:03 128847_3.jpg
    -rw-r--r-- 1 2001 sites 188893 2009-08-13 10:03 128847_4.jpg
    -rw-r--r-- 1 2001 sites 177707 2009-08-13 10:03 128848_1.jpg

    Can anyone see what mistake im making as i dont want anything over 14 days old?

    Regards

    Sam
    A man who won't die for something is not fit to live.
    Martin Luther King, Jr.

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: simple mtime issue

    Hi lolium.

    'find' by defualt searches for all entries: files and directories. It looks like some directories are being found, and the 'ls' is printing the whole directory.

    Try restricting the search just for files:
    Code:
    find .  -type f  -name '*.*' -mtime -14 -exec ls -l {} \;
    Hope it helps, and tell us how it goes.
    Regards.

  3. #3
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: simple mtime issue

    That command should work. What do you get if you use stat on one of those files instead of ls? Stat will diplsy all of the time stamps on the file.

    Also is this on ext3/ext4 formatted that is local or mounted via NFS?

  4. #4
    Join Date
    May 2009
    Location
    Bradford UK
    Beans
    45
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: simple mtime issue

    That's perfect thank you! I just assumed that with the directory only containing files it wouldn't be an issue, guess i shouldn't have just assumed.

    Thank you

    thank you for the reply hawk but papibe resolved my issue
    A man who won't die for something is not fit to live.
    Martin Luther King, Jr.

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: simple mtime issue

    Great!

    Please mark the thread solved (read here), when you have the chance.

    Regards.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •