<?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: Scripting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692441#M659002</link>
    <description>&amp;gt;&amp;gt; I've tried catting the file into awk -F ".", &lt;BR /&gt;&lt;BR /&gt;( Never cat a file into awk. A waste of time! :-)&lt;BR /&gt;&lt;BR /&gt;The problem with specifying a period as field separator is that whitepsace is no longer a separator. So you need to speciy both.&lt;BR /&gt;And then the problem become that there is a variable number of fields, which you can resolve by printing relative to the end.&lt;BR /&gt;The awk solution then becomes:&lt;BR /&gt;&lt;BR /&gt;$ awk -F'[. ]' '{print $1,$(NF-2) "." $(NF-1) "." $NF}' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;But it is easier to just replace all non-spaces after the first period with nothing:&lt;BR /&gt;&lt;BR /&gt;$ awk  '{sub (/\.[^ ]+/,""); print}' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;using perl...&lt;BR /&gt;&lt;BR /&gt;$ perl -pe 's/\.[^ ]+//' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;or replace everything from the first periods &lt;BR /&gt;through the first space, by a space: &lt;BR /&gt;&lt;BR /&gt;$ perl -pe 's/\..*? / /' tmp.txt&lt;BR /&gt;&lt;BR /&gt;Enjoy.&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 28 Sep 2010 18:57:10 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2010-09-28T18:57:10Z</dc:date>
    <item>
      <title>Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692437#M658998</link>
      <description>I need a bit of help with scripting.&lt;BR /&gt;&lt;BR /&gt;I have a file that I want to chop up and it's quite straightforward but I can't figure out how to do it in awk.&lt;BR /&gt;&lt;BR /&gt;The text file consists of an FQDN and a OS version number and I want to replicate it so that it's just hostname and OS version. For example:&lt;BR /&gt;&lt;BR /&gt;box1.xyz.com  07.12.00&lt;BR /&gt;box2.xyz.com  08.43.01&lt;BR /&gt;box3.xyz.co.uk  06.22.02&lt;BR /&gt;&lt;BR /&gt;and I want to just strip that down to:&lt;BR /&gt;&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;I've tried catting the file into awk -F ".", etc but I'm braindead today. Can you have awk called within an awk statement?&lt;BR /&gt;&lt;BR /&gt;Thanks for any help.&lt;BR /&gt;&lt;BR /&gt;jackie</description>
      <pubDate>Tue, 28 Sep 2010 14:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692437#M658998</guid>
      <dc:creator>jackie baron_1</dc:creator>
      <dc:date>2010-09-28T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692438#M658999</link>
      <description>Shalom jackie&lt;BR /&gt;&lt;BR /&gt;while read -r DL&lt;BR /&gt;do&lt;BR /&gt;  host=$(echo $DL | awk -F. '{print $1}')&lt;BR /&gt;  part2=$(echo $DL | awk  '{print $2}')&lt;BR /&gt;  echo "$host $part2"&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;file is wherever this data is sitting.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 28 Sep 2010 15:04:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692438#M658999</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2010-09-28T15:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692439#M659000</link>
      <description>while read a &lt;BR /&gt;do&lt;BR /&gt;   echo ${a%%.*} ${a#* }&lt;BR /&gt;done &amp;lt; inputfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt; awk  ' { split($1,a,"."); printf "%s %s\n" ,a[1], $2 ;}' &lt;INPUTFILE&gt;&lt;/INPUTFILE&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Sep 2010 15:16:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692439#M659000</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2010-09-28T15:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692440#M659001</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Laurent: while read a; do&lt;BR /&gt;&lt;BR /&gt;You can simplify by reading two parms:&lt;BR /&gt;while read host_ip version; do&lt;BR /&gt;   echo ${host_ip%%.*} ${version}&lt;BR /&gt;done &amp;lt; inputfile</description>
      <pubDate>Tue, 28 Sep 2010 16:04:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692440#M659001</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-09-28T16:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692441#M659002</link>
      <description>&amp;gt;&amp;gt; I've tried catting the file into awk -F ".", &lt;BR /&gt;&lt;BR /&gt;( Never cat a file into awk. A waste of time! :-)&lt;BR /&gt;&lt;BR /&gt;The problem with specifying a period as field separator is that whitepsace is no longer a separator. So you need to speciy both.&lt;BR /&gt;And then the problem become that there is a variable number of fields, which you can resolve by printing relative to the end.&lt;BR /&gt;The awk solution then becomes:&lt;BR /&gt;&lt;BR /&gt;$ awk -F'[. ]' '{print $1,$(NF-2) "." $(NF-1) "." $NF}' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;But it is easier to just replace all non-spaces after the first period with nothing:&lt;BR /&gt;&lt;BR /&gt;$ awk  '{sub (/\.[^ ]+/,""); print}' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;using perl...&lt;BR /&gt;&lt;BR /&gt;$ perl -pe 's/\.[^ ]+//' tmp.txt&lt;BR /&gt;box1 07.12.00&lt;BR /&gt;box2 08.43.01&lt;BR /&gt;box3 06.22.02&lt;BR /&gt;&lt;BR /&gt;or replace everything from the first periods &lt;BR /&gt;through the first space, by a space: &lt;BR /&gt;&lt;BR /&gt;$ perl -pe 's/\..*? / /' tmp.txt&lt;BR /&gt;&lt;BR /&gt;Enjoy.&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Sep 2010 18:57:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692441#M659002</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-09-28T18:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692442#M659003</link>
      <description>How about a sed option&lt;BR /&gt;&lt;BR /&gt;sed 's/\([^.]*\).* \([^ ]*\)/\1 \2/p'</description>
      <pubDate>Wed, 29 Sep 2010 10:12:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692442#M659003</guid>
      <dc:creator>David DiBiase</dc:creator>
      <dc:date>2010-09-29T10:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692443#M659004</link>
      <description>Thanks so much guys.&lt;BR /&gt;&lt;BR /&gt;Dave, the sed one didn't work but I guess I can tweak it.</description>
      <pubDate>Wed, 29 Sep 2010 12:11:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/4692443#M659004</guid>
      <dc:creator>jackie baron_1</dc:creator>
      <dc:date>2010-09-29T12:11:17Z</dc:date>
    </item>
  </channel>
</rss>

