<?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: sort or awk? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695183#M56478</link>
    <description>thanks guys... but those sort each directory... what I am trying to achieve is an entire list of files within different directories that are given as just a list of files in date order (trying to avoid individual ls -ltr of each directory.)</description>
    <pubDate>Tue, 02 Apr 2002 12:38:50 GMT</pubDate>
    <dc:creator>Nik_1</dc:creator>
    <dc:date>2002-04-02T12:38:50Z</dc:date>
    <item>
      <title>sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695174#M56469</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Calling all awk gurus! I am trying to sort a group of files by date order... using the following:&lt;BR /&gt;&lt;BR /&gt;ls -la |sort -r -k 6&lt;BR /&gt;&lt;BR /&gt;This sort the list by field 6 (the month) but it sort it alphabetically... is there anyway to sort this using the calender format? so as this is reverse, I'm hoping for:&lt;BR /&gt;&lt;BR /&gt;Dec&lt;BR /&gt;Dec&lt;BR /&gt;Mar&lt;BR /&gt;Jan&lt;BR /&gt;etc... etc...&lt;BR /&gt;&lt;BR /&gt;thanks.&lt;BR /&gt;Nik</description>
      <pubDate>Tue, 02 Apr 2002 10:30:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695174#M56469</guid>
      <dc:creator>Nik_1</dc:creator>
      <dc:date>2002-04-02T10:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695175#M56470</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Will ls -lrt not give you what you want?&lt;BR /&gt;&lt;BR /&gt;Paula</description>
      <pubDate>Tue, 02 Apr 2002 10:33:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695175#M56470</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-04-02T10:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695176#M56471</link>
      <description>NONE.&lt;BR /&gt;&lt;BR /&gt;Use -t flag of ls&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ls -t ... or ls -rt ( for reverse order)</description>
      <pubDate>Tue, 02 Apr 2002 10:34:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695176#M56471</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-04-02T10:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695177#M56472</link>
      <description>Neither :-)&lt;BR /&gt;"ls -lt" or "ls -lrt", depending on whether you want ascending or descending order. &lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 10:34:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695177#M56472</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-04-02T10:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695178#M56473</link>
      <description>Complete moment of madness there! sorry!&lt;BR /&gt;of course, you're all correct... have 10 points each for taking the time to answer my question! :)</description>
      <pubDate>Tue, 02 Apr 2002 10:41:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695178#M56473</guid>
      <dc:creator>Nik_1</dc:creator>
      <dc:date>2002-04-02T10:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695179#M56474</link>
      <description>Hang on a second... it could be more complicated than I thought...&lt;BR /&gt;What I'm trying to do is a find command to find the 10 most recent documents within a directory (and all subs). So I'm using the find command with -mtime and then sending all output that it finds, to a temporary file.. which I would then like to sort by month (field 6) not alphabetically but by calender...  any ideas again!? potential for even more points now! :)</description>
      <pubDate>Tue, 02 Apr 2002 10:57:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695179#M56474</guid>
      <dc:creator>Nik_1</dc:creator>
      <dc:date>2002-04-02T10:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695180#M56475</link>
      <description>Hi Nik,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;find . -type d -exec ls -lrt {} \;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Tue, 02 Apr 2002 11:20:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695180#M56475</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-04-02T11:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695181#M56476</link>
      <description>Hi Again,&lt;BR /&gt;&lt;BR /&gt;Or try this if you want only the first 10 occurrence:&lt;BR /&gt;for i in `find . -type d -print                &lt;BR /&gt;do&lt;BR /&gt; ls -lrt $i | head -10&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Tue, 02 Apr 2002 11:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695181#M56476</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-04-02T11:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695182#M56477</link>
      <description>If the temp file can contain all files, and it is not /huge/ (iow, it would also fit in memory), it is easy to write a perl script&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use File::Find;&lt;BR /&gt;&lt;BR /&gt;my @dir = (".");&lt;BR /&gt;my @files;&lt;BR /&gt;&lt;BR /&gt;find (sub {&lt;BR /&gt;    -M $_ &amp;lt; 0.9 and return; # Too new&lt;BR /&gt;    -M  _ &amp;gt; 6.4 and return; # Too old&lt;BR /&gt;    push @files, $File::Find::name;&lt;BR /&gt;    }, @dir);&lt;BR /&gt;&lt;BR /&gt;my @sorted_by_date = sort { -M $a &amp;lt;=&amp;gt; -M $b } @files;&lt;BR /&gt;&lt;BR /&gt;print "Newest 5: @sorted_by_date[0..4]\n";&lt;BR /&gt;print "Oldest 5: @sorted_by_date[-5..-1]\n";&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 11:53:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695182#M56477</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-04-02T11:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695183#M56478</link>
      <description>thanks guys... but those sort each directory... what I am trying to achieve is an entire list of files within different directories that are given as just a list of files in date order (trying to avoid individual ls -ltr of each directory.)</description>
      <pubDate>Tue, 02 Apr 2002 12:38:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695183#M56478</guid>
      <dc:creator>Nik_1</dc:creator>
      <dc:date>2002-04-02T12:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695184#M56479</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;find . -type d -xdev | xargs ll -ltr &amp;gt; /tmp/file1&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 02 Apr 2002 12:49:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695184#M56479</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-02T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695185#M56480</link>
      <description>Nik,&lt;BR /&gt;&lt;BR /&gt;Are you trying to say you want the MONTH's sorted in reverse, like this:&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;OCT&lt;BR /&gt;NOV&lt;BR /&gt;MAY&lt;BR /&gt;MAR&lt;BR /&gt;JUN&lt;BR /&gt;JUL&lt;BR /&gt;JAN&lt;BR /&gt;FEB&lt;BR /&gt;DEC&lt;BR /&gt;AUG&lt;BR /&gt;APR&lt;BR /&gt;&lt;BR /&gt;which is what an APLHA sort will do??????????&lt;BR /&gt;&lt;BR /&gt;Which I don't think you want. What you really need to do is look at procura's perl example and modify it for what you want.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 02 Apr 2002 12:53:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695185#M56480</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-04-02T12:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695186#M56481</link>
      <description>Hi Harry,&lt;BR /&gt;No I'm trying to work out how to get them sorted like...&lt;BR /&gt;&lt;BR /&gt;Dec&lt;BR /&gt;Nov&lt;BR /&gt;Oct&lt;BR /&gt;Sep&lt;BR /&gt;Aug</description>
      <pubDate>Tue, 02 Apr 2002 12:56:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695186#M56481</guid>
      <dc:creator>Nik_1</dc:creator>
      <dc:date>2002-04-02T12:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695187#M56482</link>
      <description>in my perl script, '@dir' can be any list of sub-folders, like&lt;BR /&gt;&lt;BR /&gt;@dir = ("/tmp", "/etc", "/usr/sbin");&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;@dir = qw( /tmp/blah /tmp/foo/ahhrg /stand /usr/etc );&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 14:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695187#M56482</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-04-02T14:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695188#M56483</link>
      <description>Nik:&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl&lt;BR /&gt;#&lt;BR /&gt;# written by harry d brown jr&lt;BR /&gt;#&lt;BR /&gt;# get the "option"&lt;BR /&gt;#&lt;BR /&gt;$opts = $ARGV[0];&lt;BR /&gt;#&lt;BR /&gt;if ( ( $#ARGV &amp;lt; 0 ) || ( $opts !~ /-atime|-ctime|-mtime/ ) ) {&lt;BR /&gt;   print "Usage : ./o [-atime|-ctime|-mtime] [dirpath ...]\n";&lt;BR /&gt;   exit 1;&lt;BR /&gt;}&lt;BR /&gt;#&lt;BR /&gt;# get directories to list&lt;BR /&gt;#&lt;BR /&gt;$DIRS2list = "";&lt;BR /&gt;for ( $i=1 ; $i le $#ARGV ; $i++ ) {&lt;BR /&gt;  $DIRS2list .= $ARGV[$i] . " ";&lt;BR /&gt;}&lt;BR /&gt;#&lt;BR /&gt;# find the files, and not we are only using real files, to use all&lt;BR /&gt;# remove the "-type f"&lt;BR /&gt;#&lt;BR /&gt;open(FILELIST,"find $DIRS2list -type f|");&lt;BR /&gt;#&lt;BR /&gt;$filemat="";&lt;BR /&gt;#&lt;BR /&gt;# a little trickery to get the optins and LS commands&lt;BR /&gt;#&lt;BR /&gt;$LSOPTS = "u c";&lt;BR /&gt;$OPTSTR = "amc";&lt;BR /&gt;$DATEIDX = index($OPTSTR,substr($opts,1,1));&lt;BR /&gt;$DATECHAR = substr($LSOPTS,$DATEIDX,1);&lt;BR /&gt;#&lt;BR /&gt;# read the file list from find&lt;BR /&gt;#&lt;BR /&gt;while (&lt;FILELIST&gt;) {&lt;BR /&gt;   chop;&lt;BR /&gt;   ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$&lt;BR /&gt;blocks) = stat $_;&lt;BR /&gt;   $DATEFIELD[0] = $atime;&lt;BR /&gt;   $DATEFIELD[1] = $mtime;&lt;BR /&gt;   $DATEFIELD[2] = $ctime;&lt;BR /&gt;   $date2use = $DATEFIELD[$DATEIDX];&lt;BR /&gt;   push @filemat,$date2use . " " . $_;&lt;BR /&gt;}&lt;BR /&gt;#&lt;BR /&gt;# sort the array on the time the user choose&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;@newmat = sort { $b &amp;lt;=&amp;gt; $a } @filemat;&lt;BR /&gt;#&lt;BR /&gt;# spit the listing out&lt;BR /&gt;#&lt;BR /&gt;foreach $filestuff ( @newmat ) {&lt;BR /&gt;   ($filetime,$filename) = split(/ /,$filestuff);&lt;BR /&gt;   print `ls -l$DATECHAR $filename`;&lt;BR /&gt;}&lt;BR /&gt;# end of script&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You might have to change the PATH to perl, and the options are this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;./prog -atime /tmp /var/tmp /whatever &lt;BR /&gt;&lt;BR /&gt;-atime = last access time&lt;BR /&gt;-mtime = last file change&lt;BR /&gt;-ctime = last INODE change&lt;BR /&gt;&lt;BR /&gt;use a "." (period) for the current directory.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;procura, what do ya think?&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;/FILELIST&gt;</description>
      <pubDate>Tue, 02 Apr 2002 15:52:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695188#M56483</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-04-02T15:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695189#M56484</link>
      <description>Nik,&lt;BR /&gt;&lt;BR /&gt;If you still want the find command to do what you are looking for, then here it is:&lt;BR /&gt;&lt;BR /&gt;ls -lt `find .  -mtime +10 -type f -print`&lt;BR /&gt;&lt;BR /&gt;This will find all files older than 10 days from current date and will sort in the order that you need ...&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shabu</description>
      <pubDate>Tue, 02 Apr 2002 20:34:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695189#M56484</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-04-02T20:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695190#M56485</link>
      <description>Nik,&lt;BR /&gt;&lt;BR /&gt;I forgot to mention one more thing ... there is a catch ... if this doesn't find any files older than 10 days then it would list everything in the current directory or from wherever you are executing it ...&lt;BR /&gt;&lt;BR /&gt;-Shabu</description>
      <pubDate>Tue, 02 Apr 2002 20:56:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695190#M56485</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-04-02T20:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: sort or awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695191#M56486</link>
      <description>Hi Nik:&lt;BR /&gt;&lt;BR /&gt;Hi Nik:&lt;BR /&gt;&lt;BR /&gt;'sort' will serve quite well for your purpose.  You simply need to describe the sort key with the '-M' option to cause the order of the month names to be compared such that JAN &amp;lt; FEB &amp;lt; ... &amp;lt; DEC.&lt;BR /&gt;&lt;BR /&gt;Have a look at the man pages for 'sort'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Apr 2002 22:21:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-or-awk/m-p/2695191#M56486</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-04-02T22:21:44Z</dc:date>
    </item>
  </channel>
</rss>

