<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find the most recent file in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172236#M50674</link>
    <description>Sorry - that will give dirs too, so:&lt;BR /&gt;&lt;BR /&gt;find . -exec ls -lt {} \; | grep -v "^total" | grep -v "^d" | head -1&lt;BR /&gt;&lt;BR /&gt;Then you can use cut or awk to get only the file name.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 29 Apr 2009 06:10:27 GMT</pubDate>
    <dc:creator>Mark McDonald_2</dc:creator>
    <dc:date>2009-04-29T06:10:27Z</dc:date>
    <item>
      <title>Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172228#M50666</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;How to find the most recent files (Created or modified) under a specified directory and recursively in sub dirs ?&lt;BR /&gt;&lt;BR /&gt;any Idea ?&lt;BR /&gt;&lt;BR /&gt;Thank you very much&lt;BR /&gt;Den</description>
      <pubDate>Tue, 28 Apr 2009 12:44:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172228#M50666</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-04-28T12:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172229#M50667</link>
      <description>Hi,&lt;BR /&gt;You could do for example&lt;BR /&gt;find /directory -ctime 1 -o -mtime 1 -depth -type f | xargs ls -al</description>
      <pubDate>Tue, 28 Apr 2009 14:03:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172229#M50667</guid>
      <dc:creator>smatador</dc:creator>
      <dc:date>2009-04-28T14:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172230#M50668</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;It's not enough because if no activities from more days ... &lt;BR /&gt;&lt;BR /&gt;I need something more ...strongest to answer: THIS is the last modified or created file !!!&lt;BR /&gt;&lt;BR /&gt;Do you see what I mean ?&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Tue, 28 Apr 2009 17:08:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172230#M50668</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-04-28T17:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172231#M50669</link>
      <description>&lt;!--!*#--&gt;There might be some clever perl thing (about&lt;BR /&gt;which I know nothing), and it'd be pretty&lt;BR /&gt;easy to do in DCL, but "recursively" makes it&lt;BR /&gt;hard in a UNIX-like environment.  (At least&lt;BR /&gt;_I_ don't see an easy way to do it.)&lt;BR /&gt;&lt;BR /&gt;"ls -Rt --full-time" would give you all the&lt;BR /&gt;information you need, but not in a convenient&lt;BR /&gt;form.  The directory names are on separate&lt;BR /&gt;lines, but the first line after "total"&lt;BR /&gt;would be the newest file in that directory.&lt;BR /&gt;Combine the directory name with the file&lt;BR /&gt;name, sort by the date-time field(s), and&lt;BR /&gt;you're done.&lt;BR /&gt;&lt;BR /&gt;You could also do a "find -type d" to do the&lt;BR /&gt;directory recursion, and in each directory do&lt;BR /&gt;the "ls -t --full-time" to get the newest&lt;BR /&gt;file there.  Collect all those, and sort them&lt;BR /&gt;by the date-time field(s).&lt;BR /&gt;&lt;BR /&gt;It looks to me like too much work.&lt;BR /&gt;&lt;BR /&gt;Why do you care?</description>
      <pubDate>Tue, 28 Apr 2009 18:14:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172231#M50669</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-04-28T18:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172232#M50670</link>
      <description>I don't try it yet but it seem very interesting. Look at this script&lt;BR /&gt;&lt;A href="http://www.pixelbeat.org/scripts/newest" target="_blank"&gt;http://www.pixelbeat.org/scripts/newest&lt;/A&gt;</description>
      <pubDate>Tue, 28 Apr 2009 18:50:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172232#M50670</guid>
      <dc:creator>smatador</dc:creator>
      <dc:date>2009-04-28T18:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172233#M50671</link>
      <description>&lt;!--!*#--&gt;Hi Den:&lt;BR /&gt;&lt;BR /&gt;I'll use Perl for the reason that Steven cited.&lt;BR /&gt;&lt;BR /&gt;There is _NO_ such thing as a creation timestamp in Unix or Linux.  The 'ctime' field of the stat() structure is the last _change_ timestamp for an inode.  Changing the permissions, ownership or name of a file or directory alters this timestamp.  Writing to a file alters the 'mtime'.&lt;BR /&gt;&lt;BR /&gt;This Perl script will return _files_ in the order of their last modification timestampe (or 'mtime').  Specifiy one or more directories to recursively search.  If no arguments are given, your current working directory will be used.  The files are sorted in descending age (newest first) thus allowing you to (conveniently) take the 'head' of the list returned:&lt;BR /&gt;&lt;BR /&gt;# cat ./fileage&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use File::Find;&lt;BR /&gt;my @a;&lt;BR /&gt;my @paths = @ARGV ? @ARGV : ('.');&lt;BR /&gt;find( sub { push @a, [ $File::Find::name, ( stat($_) )[9] ] if -f $_ },&lt;BR /&gt;    @paths );&lt;BR /&gt;for ( sort { $b-&amp;gt;[1] &amp;lt;=&amp;gt; $a-&amp;gt;[1] } @a ) {&lt;BR /&gt;    print join " ", scalar localtime( @$_[1] ), @$_[0], "\n";&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;# ./fileage /root |head -3&lt;BR /&gt;Tue Apr 28 14:26:45 2009 /root/.sh_history&lt;BR /&gt;Sat Apr 25 14:40:02 2009 /root/bigfile&lt;BR /&gt;Thu Apr 16 15:18:21 2009 /root/jrfsig.pl&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Apr 2009 22:41:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172233#M50671</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-28T22:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172234#M50672</link>
      <description>You could use the stat command to get modification time in a convenient format.&lt;BR /&gt;Then the sort command would be able to order the files by time.&lt;BR /&gt;&lt;BR /&gt;find . -exec stat -c '%Y %n' {} \; | sort -n | less&lt;BR /&gt;&lt;BR /&gt;There may be many files with the same modification time.&lt;BR /&gt;One second resolution is actually a very long time for a fast computer.&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Apr 2009 03:50:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172234#M50672</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2009-04-29T03:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172235#M50673</link>
      <description>find . -exec ls -lt {} \; | grep -v "^total" | head -1&lt;BR /&gt;&lt;BR /&gt;Then you can use cut or awk to get only the file name.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Apr 2009 06:07:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172235#M50673</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-29T06:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172236#M50674</link>
      <description>Sorry - that will give dirs too, so:&lt;BR /&gt;&lt;BR /&gt;find . -exec ls -lt {} \; | grep -v "^total" | grep -v "^d" | head -1&lt;BR /&gt;&lt;BR /&gt;Then you can use cut or awk to get only the file name.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Apr 2009 06:10:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172236#M50674</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-29T06:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172237#M50675</link>
      <description>Sorry - It worked on a small structure I created (maybe by fluke) but doesnt work on larger numbers of files.</description>
      <pubDate>Wed, 29 Apr 2009 06:16:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172237#M50675</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-29T06:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most recent file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172238#M50676</link>
      <description>Variations presented here give some intersting clues. &lt;BR /&gt;&lt;BR /&gt;Thanks to all</description>
      <pubDate>Mon, 14 Sep 2009 17:12:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/find-the-most-recent-file/m-p/5172238#M50676</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-09-14T17:12:10Z</dc:date>
    </item>
  </channel>
</rss>

