<?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: awk command question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353590#M192897</link>
    <description>oops that should have been &lt;BR /&gt;ENVIRON&lt;BR /&gt;and not &lt;BR /&gt;ENIVRON</description>
    <pubDate>Tue, 10 Aug 2004 13:45:23 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2004-08-10T13:45:23Z</dc:date>
    <item>
      <title>awk command question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353587#M192894</link>
      <description>&lt;BR /&gt;I am creating a file if userid and uid from the passwd file using:&lt;BR /&gt;&lt;BR /&gt;cat /etc/passwd | awk -F":" {print $1 ,$3}&lt;BR /&gt;&lt;BR /&gt;but I also need to insert the hostname into the output, is there a way get this into the awk statement, I already have a variable set for HOST from a command:&lt;BR /&gt;HOST=`hostname`&lt;BR /&gt;issued earlier in the script.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Aug 2004 12:31:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353587#M192894</guid>
      <dc:creator>MikeL_4</dc:creator>
      <dc:date>2004-08-10T12:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: awk command question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353588#M192895</link>
      <description>Hi Mike,&lt;BR /&gt;&lt;BR /&gt;You could try using the -v option for awk to set a variable like "HOST" equal to the local hostname and then print the results like this:&lt;BR /&gt;&lt;BR /&gt;cat /etc/passwd | awk -v HOST=`hostname` -F":" '{print HOST, $1 ,$3}'&lt;BR /&gt;&lt;BR /&gt;On my system this returns:&lt;BR /&gt;&lt;BR /&gt;ros87252 root 0&lt;BR /&gt;ros87252 daemon 1&lt;BR /&gt;ros87252 bin 2&lt;BR /&gt;ros87252 sys 3&lt;BR /&gt;ros87252 adm 4&lt;BR /&gt;ros87252 uucp 5&lt;BR /&gt;ros87252 lp 9&lt;BR /&gt;ros87252 nuucp 11&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Tue, 10 Aug 2004 12:36:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353588#M192895</guid>
      <dc:creator>Dave Olker</dc:creator>
      <dc:date>2004-08-10T12:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: awk command question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353589#M192896</link>
      <description>another way using awk:&lt;BR /&gt;&lt;BR /&gt;If you have a recent version of awk, such as on 11i, you can do it this way:&lt;BR /&gt;&lt;BR /&gt;awk -F":" '{&lt;BR /&gt;print $1, $3, ENIVRON["HOST"];&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;I'm not sure if HOST needs to be exported from the environment or not.&lt;BR /&gt;&lt;BR /&gt;or you can just do it in the shell&lt;BR /&gt;&lt;BR /&gt;oldIFS="$IFS"&lt;BR /&gt;IFS=":"&lt;BR /&gt;while read userid x uid stuff&lt;BR /&gt;do&lt;BR /&gt;print $userid $uid $HOST&lt;BR /&gt;done &amp;lt; /etc/passwd&lt;BR /&gt;IFS="$oldIFS"</description>
      <pubDate>Tue, 10 Aug 2004 13:43:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353589#M192896</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-08-10T13:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: awk command question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353590#M192897</link>
      <description>oops that should have been &lt;BR /&gt;ENVIRON&lt;BR /&gt;and not &lt;BR /&gt;ENIVRON</description>
      <pubDate>Tue, 10 Aug 2004 13:45:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-command-question/m-p/3353590#M192897</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-08-10T13:45:23Z</dc:date>
    </item>
  </channel>
</rss>

