<?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: Need help with a script (fixing some formatting) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892658#M103243</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;you can use awk and counting the fields not from the beginnig but from the end:&lt;BR /&gt;&lt;BR /&gt;# cat inputfile&lt;BR /&gt;a b c d e &lt;BR /&gt;a   c d e &lt;BR /&gt;# awk '{printf("%s %s\n",$(NF-1),$NF)}' inputfile&lt;BR /&gt;d e&lt;BR /&gt;d e&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
    <pubDate>Thu, 30 Jan 2003 06:09:23 GMT</pubDate>
    <dc:creator>Christian Gebhardt</dc:creator>
    <dc:date>2003-01-30T06:09:23Z</dc:date>
    <item>
      <title>Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892652#M103237</link>
      <description>I am building a script that extracts information from the commands "last -R" and "lastb -R" &lt;BR /&gt;&lt;BR /&gt;which will be used to create pipe separated files that will later be imported into Oracle &lt;BR /&gt;&lt;BR /&gt;database tables.  This is to facilitate reading and viewing to some managers who want to &lt;BR /&gt;&lt;BR /&gt;look at system access info using some interface repots through access or something like &lt;BR /&gt;&lt;BR /&gt;that.&lt;BR /&gt;&lt;BR /&gt;Well, most of the the script's syntax I am using is included in my next posting as an &lt;BR /&gt;&lt;BR /&gt;attachment.  Where I need help is with the formatting that takes place with what &lt;BR /&gt;I get with "lastb -R", attached is a detailed explanation of my dilemma.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Jan 2003 02:22:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892652#M103237</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2003-01-30T02:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892653#M103238</link>
      <description>Let me add the script now...&lt;BR /&gt;&lt;BR /&gt;Oh, and let me toss another question, you may see the vi command I used in the script.  What I was trying to do there was eliminate the very last line of the of the files because it was coming out blank and I did not need it.  How can I remove the last line of a file (no matter how many lines it has and I won't know -- well, I could know using wc?)</description>
      <pubDate>Thu, 30 Jan 2003 02:34:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892653#M103238</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2003-01-30T02:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892654#M103239</link>
      <description>grep -v "^$" file&lt;BR /&gt;will exclude all blank line.&lt;BR /&gt;&lt;BR /&gt;You script is too big to read for me.</description>
      <pubDate>Thu, 30 Jan 2003 02:42:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892654#M103239</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-01-30T02:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892655#M103240</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I think you can take care of your lastb problem a couple of different ways.  Take a look at the 'cut' command.  You can specify columns for cutting with that command so you should be able to specify a field.  Or, you could use awk and the substr function to break out the strings.  Probably the best way to do it would be with Perl.  I think there might even be a Perl module that reads the last and lastb information from wtmp/btmp for you.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Jan 2003 02:45:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892655#M103240</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-30T02:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892656#M103241</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;To eliminate the last line of the file, do this:&lt;BR /&gt;&lt;BR /&gt;# sed -e '$d' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;As far as the login name containing blanks, I'd suggest you unconditionally treat the extent of the first field as 8-characters (which should be the maximum for a login name) and then proceed to reformat with pipe characters.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 30 Jan 2003 02:48:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892656#M103241</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-01-30T02:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892657#M103242</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Below is a simple script that does a lastb -R and outputs into result as a comma seperated file.&lt;BR /&gt;&lt;BR /&gt;lastb -R |sed 's/ /#/g' |while read line&lt;BR /&gt;do&lt;BR /&gt;USER=$(echo $line|cut -c 1-8)&lt;BR /&gt;CHOPPED=$(echo $line|sed 's/'$USER'/ /g'|sed 's/#/ /g')&lt;BR /&gt;FIRST=$(echo $USER|sed 's/#/ /g')&lt;BR /&gt;PTS=$(echo $CHOPPED|awk '{print $1}')&lt;BR /&gt;SYS=$(echo $CHOPPED|awk '{print $2}')&lt;BR /&gt;echo "$FIRST,$PTS,$SYS" &amp;gt;&amp;gt; result&lt;BR /&gt;done         &lt;BR /&gt;&lt;BR /&gt;The trick here is to replace blanks with a special character, cut first 8 chars, remove them from the line and use awk to seperate the fields and then replace the character back with a space. So, this script may give wrong results if that character is originally part of the failed login. &lt;BR /&gt;&lt;BR /&gt;But you can use similar logic to achieve what you need.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 30 Jan 2003 03:42:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892657#M103242</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-01-30T03:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892658#M103243</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;you can use awk and counting the fields not from the beginnig but from the end:&lt;BR /&gt;&lt;BR /&gt;# cat inputfile&lt;BR /&gt;a b c d e &lt;BR /&gt;a   c d e &lt;BR /&gt;# awk '{printf("%s %s\n",$(NF-1),$NF)}' inputfile&lt;BR /&gt;d e&lt;BR /&gt;d e&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 30 Jan 2003 06:09:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892658#M103243</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2003-01-30T06:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892659#M103244</link>
      <description>Hi Adam,&lt;BR /&gt;lastb -R seems to output lines with fields of fixed length. Why not just cut them up as in the attached script?  &lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Thu, 30 Jan 2003 10:44:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892659#M103244</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-01-30T10:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a script (fixing some formatting)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892660#M103245</link>
      <description>Sorry I did not reply to these postings until today, but I work Fri-Mon, and I could not really apply the answers until now that I got back.  How is it that I did not apply John's logic from the beginning, very simple, but effective.  I think I can really use that in this case.&lt;BR /&gt;&lt;BR /&gt;Thanks everyone for your participation!</description>
      <pubDate>Fri, 31 Jan 2003 17:15:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-a-script-fixing-some-formatting/m-p/2892660#M103245</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2003-01-31T17:15:29Z</dc:date>
    </item>
  </channel>
</rss>

