<?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: help with script break down .. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677485#M907320</link>
    <description>I thought it was the -c option but I never took that out. I only modified the fist last not the 2nd one. &lt;BR /&gt;&lt;BR /&gt;Richard</description>
    <pubDate>Wed, 06 Mar 2002 19:30:42 GMT</pubDate>
    <dc:creator>someone_4</dc:creator>
    <dc:date>2002-03-06T19:30:42Z</dc:date>
    <item>
      <title>help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677482#M907317</link>
      <description>Hello everyone .. I got this script that someone posted for me on another post. I am adding it to a bigger script and i am playing with it to get the data format that I want. Now I have decided that instead of just asking for script help that I want to actully understand how and why the scripts work. I think in the long run this will help me learn more. So here we go .. I need help understanding why this part is doing what it does. .. &lt;BR /&gt;#### I have &lt;BR /&gt;last | grep -v ftp |grep -v wtmp |awk ' /still logged/ { print $1 ".*still logged in"; next } { print $1 }' |sort -u | while read name&lt;BR /&gt;do&lt;BR /&gt;   last | grep -v ftp | grep -v wtmp | grep -c "^$name" | read count&lt;BR /&gt;      echo "$name \t$count"&lt;BR /&gt;      done&lt;BR /&gt;&lt;BR /&gt;# that gives me this out put .. &lt;BR /&gt;        5&lt;BR /&gt;aford.*still logged in  1&lt;BR /&gt;rbiersch.*still logged in       1&lt;BR /&gt;rleon   2&lt;BR /&gt;rleon.*still logged in  1&lt;BR /&gt;&lt;BR /&gt;# the only part I dont understand is where is the 5 comming from? And where is that outputting from without an echo?&lt;BR /&gt;&lt;BR /&gt;I changed the first line to &lt;BR /&gt;last | grep -v ftp |grep -v wtmp | grep [A-z]|&lt;BR /&gt;And when I ran it the 5 went away. Why did the 5 go away when I added the grep [A-z]?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Richard -&lt;BR /&gt;"Give a man a fish feed him for a day,teach a man to fish feed him for a lifetime"</description>
      <pubDate>Wed, 06 Mar 2002 19:21:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677482#M907317</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-03-06T19:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677483#M907318</link>
      <description>Opps here is the first script:&lt;BR /&gt;&lt;BR /&gt;last | grep -v ftp |grep -v wtmp |awk ' /still logged/ { print $1 ".*still logged in"; next } { print $1 }' |sort -u | while read name&lt;BR /&gt;do&lt;BR /&gt;   last | grep -v ftp | grep -v wtmp | grep -c "^$name" | read count&lt;BR /&gt;      echo "$name \t$count"&lt;BR /&gt;      done</description>
      <pubDate>Wed, 06 Mar 2002 19:23:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677483#M907318</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-03-06T19:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677484#M907319</link>
      <description>The 5 comes from the grep -c which is count the lines out output, therefore when you removed the -c option in your addition, the 5 would disappear.&lt;BR /&gt;&lt;BR /&gt;Hope this is what you were looking for,&lt;BR /&gt;C</description>
      <pubDate>Wed, 06 Mar 2002 19:27:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677484#M907319</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-03-06T19:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677485#M907320</link>
      <description>I thought it was the -c option but I never took that out. I only modified the fist last not the 2nd one. &lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Wed, 06 Mar 2002 19:30:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677485#M907320</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-03-06T19:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677486#M907321</link>
      <description>If you are ever curious about what a script does internally, run it with &lt;BR /&gt;&lt;BR /&gt;#!/bin/sh -x&lt;BR /&gt;&lt;BR /&gt;then when you call it from the command line do&lt;BR /&gt;&lt;BR /&gt;# ./script.sh &amp;gt; /tmp/output 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;You'll get a lot of good information out of that logfile.&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Wed, 06 Mar 2002 19:30:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677486#M907321</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-03-06T19:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677487#M907322</link>
      <description>This is what I would use instead,&lt;BR /&gt;&lt;BR /&gt;for i in `last | grep -v ftp |grep -v wtmp | awk '/still logged/{print $1}' | so&lt;BR /&gt;rt -u`&lt;BR /&gt;do&lt;BR /&gt;last $i | wc -l | read count&lt;BR /&gt;echo $i $count&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;A little clean, easier to understand, and about twice as fast. Just me though.&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Wed, 06 Mar 2002 19:49:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677487#M907322</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-03-06T19:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677488#M907323</link>
      <description>Opps, one correction&lt;BR /&gt;&lt;BR /&gt;last $i | grep still | wc -l | read count &lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Wed, 06 Mar 2002 19:51:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677488#M907323</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-03-06T19:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: help with script break down ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677489#M907324</link>
      <description>Hi Richard,&lt;BR /&gt;&lt;BR /&gt;The reason your script is behaving like this is because you're not grepping out blank lines.  Therefore, your first $name is "", which is obviously matched on every line in the second part of your script.  Just add an extra grep to fix it:&lt;BR /&gt;&lt;BR /&gt;==================================&lt;BR /&gt;last | grep -v ^$ | grep -v ftp |grep -v wtmp | awk ' /still logged/ { print $1 ".*still logged in"; next } { print $1 }' |sort -u | while read name&lt;BR /&gt;do&lt;BR /&gt;last | grep -v ftp | grep -v wtmp | grep -c "^$name" | read count&lt;BR /&gt;echo "$name \t$count"&lt;BR /&gt;done&lt;BR /&gt;===================================&lt;BR /&gt;&lt;BR /&gt;I would have written the script slightly differently, using uniq to get the count:&lt;BR /&gt;&lt;BR /&gt;last | grep -v -e ^$ -e wtmp -e ftp |&lt;BR /&gt;awk ' /still logged/ { print $1 " still logged in"; next } { print $1 }' |&lt;BR /&gt;sort | uniq -c&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 07 Mar 2002 10:07:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script-break-down/m-p/2677489#M907324</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-03-07T10:07:42Z</dc:date>
    </item>
  </channel>
</rss>

