<?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 awk problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897860#M282503</link>
    <description>I am reading a file which sometimes has two positional parameters but sometimes it has more. I.e..&lt;BR /&gt;&lt;BR /&gt;File.txt  &lt;BR /&gt;&lt;BR /&gt;/Home/temp/user  /Thisismyhome/ &lt;BR /&gt;/Home/temp/newuser  /Thisismyhome/&lt;BR /&gt;/Home/temp/bob  /Thisismyhome and something/ &lt;BR /&gt; &lt;BR /&gt;When I print $1,$2 I get&lt;BR /&gt; &lt;BR /&gt;/Home/temp/user  /Thisismyhome/ &lt;BR /&gt;/Home/temp/newuser  /Thisismyhome/&lt;BR /&gt;/Home/temp/bob  /Thisismyhome&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But I need to include the “and something/” from the last line i.e. $3 and $4  &lt;BR /&gt;&lt;BR /&gt;So I want to print something like $1, $2* (the star being to the end of the line)&lt;BR /&gt;&lt;BR /&gt;Anybody got any ideas?&lt;BR /&gt;&lt;BR /&gt;All help appreciated&lt;BR /&gt;&lt;BR /&gt;Declan&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 14 Nov 2006 06:03:41 GMT</pubDate>
    <dc:creator>Declan Heerey</dc:creator>
    <dc:date>2006-11-14T06:03:41Z</dc:date>
    <item>
      <title>awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897860#M282503</link>
      <description>I am reading a file which sometimes has two positional parameters but sometimes it has more. I.e..&lt;BR /&gt;&lt;BR /&gt;File.txt  &lt;BR /&gt;&lt;BR /&gt;/Home/temp/user  /Thisismyhome/ &lt;BR /&gt;/Home/temp/newuser  /Thisismyhome/&lt;BR /&gt;/Home/temp/bob  /Thisismyhome and something/ &lt;BR /&gt; &lt;BR /&gt;When I print $1,$2 I get&lt;BR /&gt; &lt;BR /&gt;/Home/temp/user  /Thisismyhome/ &lt;BR /&gt;/Home/temp/newuser  /Thisismyhome/&lt;BR /&gt;/Home/temp/bob  /Thisismyhome&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But I need to include the “and something/” from the last line i.e. $3 and $4  &lt;BR /&gt;&lt;BR /&gt;So I want to print something like $1, $2* (the star being to the end of the line)&lt;BR /&gt;&lt;BR /&gt;Anybody got any ideas?&lt;BR /&gt;&lt;BR /&gt;All help appreciated&lt;BR /&gt;&lt;BR /&gt;Declan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Nov 2006 06:03:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897860#M282503</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2006-11-14T06:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897861#M282504</link>
      <description>Declan,&lt;BR /&gt;until you get your awk solution:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;while read dat1 dat2&lt;BR /&gt;do&lt;BR /&gt;echo $dat1&lt;BR /&gt;echo $dat2&lt;BR /&gt;done &amp;lt; datafile&lt;BR /&gt;&lt;BR /&gt;dat1 = Data to first space&lt;BR /&gt;dat2 = All other data to end of line&lt;BR /&gt;&lt;BR /&gt;If you add dat3 to the read line:&lt;BR /&gt;dat1 = Data to first space&lt;BR /&gt;dat2 = Data from end of dat1 to second space&lt;BR /&gt;dat3 = All other data to end of line</description>
      <pubDate>Tue, 14 Nov 2006 06:14:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897861#M282504</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-11-14T06:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897862#M282505</link>
      <description>Hi Declan,&lt;BR /&gt;&lt;BR /&gt;How about:&lt;BR /&gt;&lt;BR /&gt;# awk -F' /' '{print $1,$2}' File.txt&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Tue, 14 Nov 2006 07:32:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897862#M282505</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-11-14T07:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897863#M282506</link>
      <description>Just print $0 ?&lt;BR /&gt;&lt;BR /&gt;Remember, you can also set NF.&lt;BR /&gt;So you can do: awk '{NF=4; print}' x.txt&lt;BR /&gt;&lt;BR /&gt;Just keep on printing?&lt;BR /&gt;awk '{print $1,$2,$3,$4}&lt;BR /&gt;&lt;BR /&gt;Count, using printf to avoid new-line?&lt;BR /&gt;&lt;BR /&gt;awk '{for (i=1; i&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;&lt;BR /&gt;So many ways, the best one depends on the exact problem to solve.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Nov 2006 07:50:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897863#M282506</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-11-14T07:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897864#M282507</link>
      <description>Declan,&lt;BR /&gt;and my awk solution:&lt;BR /&gt;awk '{print $1,$2=substr($0,length($1)+1)}' datafile&lt;BR /&gt;&lt;BR /&gt;Which prints the first field and then works out the string to print for field to by taking the whole line ($0) and moving the start point to print just past the length of the first field. The end point is the end of the line.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Nov 2006 08:04:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897864#M282507</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-11-14T08:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897865#M282508</link>
      <description>Thanks for all the replies, i'm going to test each one now and will update the thread when i've finished (and i'll assign points)&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;&lt;BR /&gt;Declan</description>
      <pubDate>Tue, 14 Nov 2006 08:17:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897865#M282508</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2006-11-14T08:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897866#M282509</link>
      <description>Wey hey thanks to all, as you can guess they all work in there own right but the variation i   have used is based on Peter's reply&lt;BR /&gt;&lt;BR /&gt;awk '{print$2=substr($0,length($1)+1)}' datafile.txt&lt;BR /&gt;&lt;BR /&gt;Thanks again to everyone&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Declan</description>
      <pubDate>Tue, 14 Nov 2006 08:29:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/3897866#M282509</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2006-11-14T08:29:50Z</dc:date>
    </item>
  </channel>
</rss>

