<?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: Sorting the last command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468056#M775044</link>
    <description>Try the -M option for sort. which will sort as month abbreviation:&lt;BR /&gt;&lt;BR /&gt;Leslie</description>
    <pubDate>Tue, 28 Nov 2000 18:31:03 GMT</pubDate>
    <dc:creator>Leslie Chaim</dc:creator>
    <dc:date>2000-11-28T18:31:03Z</dc:date>
    <item>
      <title>Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468052#M775040</link>
      <description>All,&lt;BR /&gt;&lt;BR /&gt;I am looking for a way to sort the output of the last command.  For example, the following script will give me a list of the last time a user has logged on, but I need it sorted by the oldest first and the latest logins last.&lt;BR /&gt;&lt;BR /&gt;It lists one entry per user and the script is all on one line with no carriage returns.&lt;BR /&gt;&lt;BR /&gt;awk -F: '{print "last | grep "$1" | head -1"}' /etc/passwd|ksh - &amp;gt; /home1/nickd/last.log&lt;BR /&gt;&lt;BR /&gt;Appreciate the assistance, Nickd</description>
      <pubDate>Tue, 28 Nov 2000 17:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468052#M775040</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-28T17:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468053#M775041</link>
      <description>Using the -r switch will sort in reverse order as well. This would be an additional switch to the sort</description>
      <pubDate>Tue, 28 Nov 2000 17:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468053#M775041</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2000-11-28T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468054#M775042</link>
      <description>I have used sort before, but not with dates.&lt;BR /&gt;&lt;BR /&gt;The output looks like this:&lt;BR /&gt;&lt;BR /&gt;smith  ttyp4      Sat Nov 25 07:15 - 10:15 (03:15)&lt;BR /&gt;&lt;BR /&gt;Sorting the Sat Nov 25 is the difficult part Rick.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2000 18:03:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468054#M775042</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-28T18:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468055#M775043</link>
      <description>Hi Nick,&lt;BR /&gt;&lt;BR /&gt;sort won't help you in this case, at least not on the 'raw' data.&lt;BR /&gt;I think that you'll need a small shell script which will convert "Nov" into "11".&lt;BR /&gt;&lt;BR /&gt;Even then, I guess that the dates are shown like they are with 'll', I  mean that hour:min is used for dates less than 6 months while year is shown for older dates.&lt;BR /&gt;&lt;BR /&gt;I wrote such a program quite a while ago, I just need to put my hands on.&lt;BR /&gt;I'll try to find it for you.&lt;BR /&gt;&lt;BR /&gt;Maybe that using the date package in perl would be easier....&lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2000 18:23:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468055#M775043</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2000-11-28T18:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468056#M775044</link>
      <description>Try the -M option for sort. which will sort as month abbreviation:&lt;BR /&gt;&lt;BR /&gt;Leslie</description>
      <pubDate>Tue, 28 Nov 2000 18:31:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468056#M775044</guid>
      <dc:creator>Leslie Chaim</dc:creator>
      <dc:date>2000-11-28T18:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468057#M775045</link>
      <description>Leslie,&lt;BR /&gt;&lt;BR /&gt;I have tried sorting and the -M does not appear to sort the Month.  Do you have specific examples?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Nickd</description>
      <pubDate>Tue, 28 Nov 2000 18:45:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468057#M775045</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-28T18:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468058#M775046</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;Try this to order the output in ascending date sequence:&lt;BR /&gt;&lt;BR /&gt;# last|sort -Mk4 -kn&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2000 19:12:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468058#M775046</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-28T19:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468059#M775047</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;Try this to order the output in ascending date sequence:&lt;BR /&gt;&lt;BR /&gt;# last|sort -Mk4 -kn5&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2000 19:13:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468059#M775047</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-28T19:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468060#M775048</link>
      <description>Further parsing per your script:&lt;BR /&gt;&lt;BR /&gt;last | awk '{if (($1 = "nickd")) print $0}' | sort -Mk4 -kn5&lt;BR /&gt;&lt;BR /&gt;This is working for me. Give thanks to JRF for providing the sort syntax.</description>
      <pubDate>Tue, 28 Nov 2000 19:31:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468060#M775048</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2000-11-28T19:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468061#M775049</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;...because I favor great precision, let me amend my post a bit to cause the output to be sorted in ascending login time within ascending login date. Thus:&lt;BR /&gt;&lt;BR /&gt;# last|sort -Mk4 -kn5 -kn6.1,6.2 -kn6.4 &lt;BR /&gt;&lt;BR /&gt;...adding Rick's filter for your total solution:&lt;BR /&gt;&lt;BR /&gt;# last|awk '{if (($1=="nickd")) print $0}'|sort -Mk4 -kn5 -kn6.1,6.2 -kn6.4&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Nov 2000 21:38:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468061#M775049</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-28T21:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468062#M775050</link>
      <description>Have you concidered using system accounting?&lt;BR /&gt;&lt;BR /&gt;man 1m runacct&lt;BR /&gt;man 1m lastlogin&lt;BR /&gt;&lt;BR /&gt;Have runacct run daily and monacct run monthly. You will find all last logins recorded to the day in&lt;BR /&gt;&lt;BR /&gt;/var/adm/acct/sum/loginlog&lt;BR /&gt;&lt;BR /&gt;in the format&lt;BR /&gt;&lt;BR /&gt;YY-MM-DD  username&lt;BR /&gt;&lt;BR /&gt;This doesn't help you if you want more specific times during the day.&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2000 23:10:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468062#M775050</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2000-11-28T23:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468063#M775051</link>
      <description>Wow, Thanks for everyone's input.&lt;BR /&gt;&lt;BR /&gt;One final step is required.&lt;BR /&gt;&lt;BR /&gt;The command/script:&lt;BR /&gt;&lt;BR /&gt;last | awk '{if (($1 = "nickd")) print $0}' | sort -Mk4 -kn5 &lt;BR /&gt;&lt;BR /&gt;Works, but only with one userid, mine.  I am terrible at awk and I was looking for a complete list of everyone that was listed in /etc/passwd.&lt;BR /&gt;&lt;BR /&gt;Thanks all.&lt;BR /&gt;Nick</description>
      <pubDate>Wed, 29 Nov 2000 13:06:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468063#M775051</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-29T13:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468064#M775052</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;With regard to your last wish, try this as a quick and brutal solution:&lt;BR /&gt;&lt;BR /&gt;/usr/bin/sh&lt;BR /&gt;IFS=:&lt;BR /&gt;while read USER NULL&lt;BR /&gt;do&lt;BR /&gt;  last|awk -v USER=$USER '{if (($1==USER)) print $0}'|sort -Mk4 -kn5 -kn6.1,6.2 &lt;BR /&gt;-kn6.4&lt;BR /&gt;done &amp;lt; /etc/passwd&lt;BR /&gt;&lt;BR /&gt;...is this that which you seek?...regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 29 Nov 2000 13:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468064#M775052</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-29T13:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468065#M775053</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Close big guy.  This is the error that I get.  &lt;BR /&gt;&lt;BR /&gt;Let me ask you something that may help this.  Can I have the output re-directed to a file first so that I can email it to myself automatically overnight when it runs?&lt;BR /&gt;&lt;BR /&gt;The source line number is 1.&lt;BR /&gt;awk: Cannot find or open file -Mk4.&lt;BR /&gt; The source line number is 1.&lt;BR /&gt;awk: Cannot find or open file -Mk4.&lt;BR /&gt; The source line number is 1.&lt;BR /&gt;&lt;BR /&gt;Thanks Nickd</description>
      <pubDate>Wed, 29 Nov 2000 13:42:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468065#M775053</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-29T13:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468066#M775054</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;I should have just posted an attachment, so here it is with the addition of output redirection and automatic mailing to 'root'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 29 Nov 2000 14:28:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468066#M775054</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-29T14:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468067#M775055</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;Oops!  Use this version (attached).  It adds redirection, mailing, and cleans up the previous log.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 29 Nov 2000 14:38:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468067#M775055</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-29T14:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468068#M775056</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;Here's one "last" [pun intended] very much less brutal solution with better output for your specifications.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 29 Nov 2000 16:58:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468068#M775056</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-29T16:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468069#M775057</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help thus far.&lt;BR /&gt;&lt;BR /&gt;One more point, I only want each user recorded once in my log, their  most recent login.&lt;BR /&gt;&lt;BR /&gt;Therefore, when I look at my log, it will show me the following:&lt;BR /&gt;&lt;BR /&gt;james     Thu Apr 20 08:00 - 08:10&lt;BR /&gt;nickd     Fri Nov 17 09:00 - 17:00&lt;BR /&gt;&lt;BR /&gt;Your report is very thorough and detailed, but one level of detail too deep, if you know what I mean.&lt;BR /&gt;&lt;BR /&gt;Sorry to drag this out.&lt;BR /&gt;&lt;BR /&gt;Nickd</description>
      <pubDate>Wed, 29 Nov 2000 19:39:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468069#M775057</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2000-11-29T19:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468070#M775058</link>
      <description>Nick:&lt;BR /&gt;&lt;BR /&gt;OK, now you can have it both ways -- run with the '-v' option for verbose output; no flags give most recent only!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 29 Nov 2000 20:30:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468070#M775058</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-11-29T20:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the last command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468071#M775059</link>
      <description>I don't know what happens come January, 2001.&lt;BR /&gt;One thing you can do is to use the following to get your last output in reverse order is:&lt;BR /&gt;&lt;BR /&gt;    last | cat -n | sort -rn | cut -f 2&lt;BR /&gt;&lt;BR /&gt;Apparently, what you want to know is the first time a user has logged in.  I suggest that you take the script from James Ferguson and append the head -1 command to the end of the last $USER line.&lt;BR /&gt;&lt;BR /&gt;One last thing:  in unix, there many ways to do the same thing and you can do just about anything you except make a decent cup of coffee.</description>
      <pubDate>Wed, 29 Nov 2000 23:50:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sorting-the-last-command/m-p/2468071#M775059</guid>
      <dc:creator>Al Langen</dc:creator>
      <dc:date>2000-11-29T23:50:26Z</dc:date>
    </item>
  </channel>
</rss>

