<?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 question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035609#M431909</link>
    <description>In that case, don't reinvent the wheel. Look for one of Bill Hassell's scripts called "bdfmegs". It already takes care of the spillover and produces nice one-line by combining the split lines.</description>
    <pubDate>Thu, 22 Mar 2007 09:22:12 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-03-22T09:22:12Z</dc:date>
    <item>
      <title>awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035604#M431904</link>
      <description>Let me first state that I am a novice scripter.  That being said, I've used awk to print fiels but is there a switch I can use to skip fields?  I want to skip $1 and doing print $2... won't work for me?  Is this possible.  Any advise would be much appreciated.  &lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;Matt</description>
      <pubDate>Thu, 22 Mar 2007 08:24:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035604#M431904</guid>
      <dc:creator>Matt Shaffer_1</dc:creator>
      <dc:date>2007-03-22T08:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035605#M431905</link>
      <description>Matt,&lt;BR /&gt;could you give an example, otherwise it is:&lt;BR /&gt;echo "a b" | awk -F' ' '{print $2}'&lt;BR /&gt;This will print "b", which is the second field.&lt;BR /&gt;&lt;BR /&gt;Please also read:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; on how to reward any useful answers given to your questions.</description>
      <pubDate>Thu, 22 Mar 2007 08:37:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035605#M431905</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-22T08:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035606#M431906</link>
      <description>The fields $1, $2, ... $NF are be default prepared by splitting the input line $0 based on white-space.&lt;BR /&gt;You can set a different seperator in the script with IFS, or on the command line with -F. Check the man page.&lt;BR /&gt;&lt;BR /&gt;And... 'skipping fields' works fine for all of us, so it is somethign you are not doing correctly.&lt;BR /&gt;&lt;BR /&gt;With that out of the way....&lt;BR /&gt;&lt;BR /&gt;What does you input look like ?&lt;BR /&gt;(attach .txt file if need be, or click 'Retain format')&lt;BR /&gt;&lt;BR /&gt;What should the output look like?&lt;BR /&gt;What are the triggers, filters, replaces?&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 08:40:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035606#M431906</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-22T08:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035607#M431907</link>
      <description>Shalom Matt,&lt;BR /&gt;&lt;BR /&gt;Quite possible.&lt;BR /&gt;&lt;BR /&gt;cat input | awk '{print $3 $4}'&lt;BR /&gt;&lt;BR /&gt;This approach assumes the data file is consistent.&lt;BR /&gt;&lt;BR /&gt;Otherwise you are best to read the data into variables and make decisions with logic after the data is read.&lt;BR /&gt;# read into variable called DATALINE&lt;BR /&gt;datavar1=$(echo $DATALINE | awk '{print $1}')&lt;BR /&gt;&lt;BR /&gt;This puts the awk results in $datavar1 after wich logic and decision trees can be used.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 22 Mar 2007 08:44:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035607#M431907</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-03-22T08:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035608#M431908</link>
      <description>To answer the question about the input...&lt;BR /&gt;&lt;BR /&gt;when I run bdf, the output of some mounts roll over to 2 lines kind of like below.  This makes it hard to pull out the data that I want so I want to say remove all $1 fields that start with /.  What I've been doing so far is bdf -l | grep ^/ and then I want to "remove" $1 so that all lines are equat.  Does that make sense?  Thanks   &lt;BR /&gt;&lt;BR /&gt;/dev/central03/lvol8&lt;BR /&gt;                     26% /CENTRAL-BKP/backup&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 09:13:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035608#M431908</guid>
      <dc:creator>Matt Shaffer_1</dc:creator>
      <dc:date>2007-03-22T09:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035609#M431909</link>
      <description>In that case, don't reinvent the wheel. Look for one of Bill Hassell's scripts called "bdfmegs". It already takes care of the spillover and produces nice one-line by combining the split lines.</description>
      <pubDate>Thu, 22 Mar 2007 09:22:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035609#M431909</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-22T09:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035610#M431910</link>
      <description>Hi Matt:&lt;BR /&gt;&lt;BR /&gt;There is no need to 'grep' with 'awk'.  Awk has regular expression pattern matching built-in.&lt;BR /&gt;&lt;BR /&gt;Consider:&lt;BR /&gt;&lt;BR /&gt;# awk '{if ($1~/#/) {next} else {print}}' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;...would skip all comments in '/etc/hosts' by matching the "#" in the first field.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 22 Mar 2007 09:26:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035610#M431910</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-22T09:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035611#M431911</link>
      <description>&amp;gt;&amp;gt; when I run bdf, the output of some mounts roll over to 2 lines kind of like below.&lt;BR /&gt;&lt;BR /&gt;Do you really think you are the first one to tackle this!? &lt;BR /&gt;Just google for 'awk bdf' and you'll find oodles of solutions. No point re-inventing the wheel! &lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1024204" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1024204&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; What I've been doing so far is bdf -l | grep ^/ and then I want to "remove" $1 so that all lines are equat. Does that make sense?&lt;BR /&gt;&lt;BR /&gt;Since you asked... No, this makes not sense.&lt;BR /&gt;&lt;BR /&gt;Why would you go through grep when awk will happily do any filter work for you right there?&lt;BR /&gt;&lt;BR /&gt;Why not add the extra segment to the partial to recreate a single full line and have all information?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;btw... do you now see why I suggested to checkmark the box before 'Retain format' just above the [submit]&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 09:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035611#M431911</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-22T09:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035612#M431912</link>
      <description>Hi Matt,&lt;BR /&gt;&lt;BR /&gt;if you want to print from $2 and the rest of the fields of each line - without worrying about the number of fields, you can try this:&lt;BR /&gt;&lt;BR /&gt;$ awk '$1="";{print $0}' infile&lt;BR /&gt;&lt;BR /&gt;(awk connoisseurs will probably find it ugly..)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 09:30:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035612#M431912</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2007-03-22T09:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035613#M431913</link>
      <description>As Clay said look at Bill Hassell's script link below:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1048509" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1048509&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;quick and dirty way to print equal number of fields from the output of bdf -l try the awk construct below:&lt;BR /&gt;&lt;BR /&gt;# bdf -l | awk '{if(NF==1) getline l;gsub(" +"," ",l);print $0l}'</description>
      <pubDate>Thu, 22 Mar 2007 09:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035613#M431913</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-03-22T09:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035614#M431914</link>
      <description>These guys gave me a lot of good feedback and things to try.  None of them have worked yet but I'm getting closer.</description>
      <pubDate>Thu, 22 Mar 2007 10:45:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/5035614#M431914</guid>
      <dc:creator>Matt Shaffer_1</dc:creator>
      <dc:date>2007-03-22T10:45:55Z</dc:date>
    </item>
  </channel>
</rss>

