<?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 printing in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072988#M92254</link>
    <description>Here is the summary of the script I use to gather disk usage reporting.&lt;BR /&gt;&lt;BR /&gt;1) get list of all disk device files&lt;BR /&gt;2) run this list through while read loop and use it to determine disk size, vg, lv and free extents using diskinfo, vgdisplay, pvdisplay commands.&lt;BR /&gt;&lt;BR /&gt;3) if none of the above are found on the disks then it is available for user.&lt;BR /&gt;&lt;BR /&gt;4) output in comma separated or formatted file for reporting.&lt;BR /&gt;&lt;BR /&gt;Example is below.&lt;BR /&gt;1/0/10/1/0.0.0,/dev/dsk/c8t0d0,EXT,P,/dev/vgdata1/adm_fsdmo84,/u01/oracle/admin/fsdmo84,143GB&lt;BR /&gt; , , ,P,/dev/vgdata1/adm_hrdmo83,/u01/oracle/admin/hrdmo83, &lt;BR /&gt; , , ,P,/dev/vgdata1/adm_qfonyx,/u01/oracle/admin/qfonyx, &lt;BR /&gt;</description>
    <pubDate>Mon, 08 Oct 2007 10:33:34 GMT</pubDate>
    <dc:creator>Tim Nelson</dc:creator>
    <dc:date>2007-10-08T10:33:34Z</dc:date>
    <item>
      <title>awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072986#M92252</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I am attempting to use awk to search the lunid that exists in one file but not the other so:&lt;BR /&gt;&lt;BR /&gt;for lunid in `awk 'FS="," {print $2}' paceds.lsfbvol.out`&lt;BR /&gt;do&lt;BR /&gt;awk -v lun=$lunid '/'"$lunid"'/ {if ( NF &amp;gt; 0) print lun,$0 &amp;gt;&amp;gt; "myoutfile"} {if ( NF == 1 ) print lun,",," &amp;gt;&amp;gt; "myoutfile"}'&lt;BR /&gt; paceds.lshostvol.out&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I am sure there is no need to run this through the shell for loop and can be done in awk.&lt;BR /&gt;&lt;BR /&gt;the first file paceds.lsfbvol.out details all luns in our Storage .....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;paceds.lshostvol.out file is missing 2 luns so I want to be able to seach the second file for all luns ($2) and if not there print the line from paceds.lsfbvol.out and have ",," if the line exists just print $0 from paceds.lsfbvol.out into myoutfile.&lt;BR /&gt;&lt;BR /&gt;a sample of the line:&lt;BR /&gt;&lt;BR /&gt;fl_olas_0_2000,2000,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;&lt;BR /&gt;thanks guys ....&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 08 Oct 2007 10:16:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072986#M92252</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-10-08T10:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072987#M92253</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;IMHO, you don't need awk, you can use something like that:&lt;BR /&gt;cat paceds.lsfbvol.out paceds.lshostvol.out | sort | uniq -u&lt;BR /&gt;&lt;BR /&gt;This will print you exactly the luns which are absent in the full list.&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Mon, 08 Oct 2007 10:27:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072987#M92253</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2007-10-08T10:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072988#M92254</link>
      <description>Here is the summary of the script I use to gather disk usage reporting.&lt;BR /&gt;&lt;BR /&gt;1) get list of all disk device files&lt;BR /&gt;2) run this list through while read loop and use it to determine disk size, vg, lv and free extents using diskinfo, vgdisplay, pvdisplay commands.&lt;BR /&gt;&lt;BR /&gt;3) if none of the above are found on the disks then it is available for user.&lt;BR /&gt;&lt;BR /&gt;4) output in comma separated or formatted file for reporting.&lt;BR /&gt;&lt;BR /&gt;Example is below.&lt;BR /&gt;1/0/10/1/0.0.0,/dev/dsk/c8t0d0,EXT,P,/dev/vgdata1/adm_fsdmo84,/u01/oracle/admin/fsdmo84,143GB&lt;BR /&gt; , , ,P,/dev/vgdata1/adm_hrdmo83,/u01/oracle/admin/hrdmo83, &lt;BR /&gt; , , ,P,/dev/vgdata1/adm_qfonyx,/u01/oracle/admin/qfonyx, &lt;BR /&gt;</description>
      <pubDate>Mon, 08 Oct 2007 10:33:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072988#M92254</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2007-10-08T10:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072989#M92255</link>
      <description>Could you provide a sample of the two input files i.e. "paceds.lsfbvol.out" and "paceds.lshostvol.out". grep(1) might be able to work just as well depending on the contents of the two files.&lt;BR /&gt;&lt;BR /&gt;~thanks</description>
      <pubDate>Mon, 08 Oct 2007 10:34:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072989#M92255</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-08T10:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072990#M92256</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;You could use a 'getline' to read your first file in a 'BEGIN' block into an array which you then process against the second file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;BEGIN{while (getline LINE &amp;lt; "paceds.lsfbvol.out" &amp;gt; 0) {a[++$i]=LINE}} &lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Oct 2007 10:55:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072990#M92256</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-08T10:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072991#M92257</link>
      <description>cat lshost |&lt;BR /&gt;awk -v f2="lsfbvol" '&lt;BR /&gt;BEGIN {&lt;BR /&gt;while ( getline &amp;lt; f2 &amp;gt; 0 ) a[$2]=1;&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;if ( a[$2] ) print "found";&lt;BR /&gt;else print "not found";&lt;BR /&gt;}</description>
      <pubDate>Mon, 08 Oct 2007 11:17:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072991#M92257</guid>
      <dc:creator>blah2blah</dc:creator>
      <dc:date>2007-10-08T11:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072992#M92258</link>
      <description>You can of course do this several ways.  If your files have the same format, you can use sort and comm, something like Victor's.&lt;BR /&gt;&lt;BR /&gt;You can create two tmp files, each prefixed by the file and the key, and then sort by key, then file and then use awk to read "pairs" of lines.&lt;BR /&gt;&lt;BR /&gt;Note: your sample script above goes to the trouble of using awk -v then you use a quoting nightmare to get $lunid inside //.  If you want a RE that's not a constant you can use:&lt;BR /&gt;awk -v lun=$lunid '$0 ~ lun { if ...&lt;BR /&gt;And you can also move that "if" into your pattern:&lt;BR /&gt;awk -v lun=$lunid '$0 ~ lun &amp;amp;&amp;amp; NF &amp;gt; 1 { ...&lt;BR /&gt;Note: I changed that NF &amp;gt; 0 to NF &amp;gt; 1 in the last line.  But you might as well remove it since if you have a match, there is one field.  And after you print it, you might as well use "exit".&lt;BR /&gt;&lt;BR /&gt;&amp;gt;if not there print the line from paceds.lsfbvol.out and have ",," if the line exists just print $0 from paceds.lsfbvol.out into myoutfile. &lt;BR /&gt;&lt;BR /&gt;Your current script can only print the values out from paceds.lshostvol.out, the file you are currently processing.&lt;BR /&gt;&lt;BR /&gt;So as Sandman asks, what is the format of each file?&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2007 03:11:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072992#M92258</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-09T03:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072993#M92259</link>
      <description>ok here is the sample form each file:&lt;BR /&gt;&lt;BR /&gt;more  paceds.lsfbvol.out&lt;BR /&gt;&lt;BR /&gt;olas_0_1000,1000,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;olas_0_1001,1001,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;olas_0_1002,1002,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;olas_0_1003,1003,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;olas_0_1004,1004,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;olas_0_1005,1005,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$2 being the lun id&lt;BR /&gt;&lt;BR /&gt;and from the file searched where the lun id does not exist:&lt;BR /&gt;&lt;BR /&gt;# more paceds.lshostvol.out&lt;BR /&gt;&lt;BR /&gt;hdisk4,IBM.2107-75FDFW1/3000,vpath0&lt;BR /&gt;hdisk5,IBM.2107-75FDFW1/3001,vpath1&lt;BR /&gt;hdisk6,IBM.2107-75FDFW1/3002,vpath2&lt;BR /&gt;hdisk7,IBM.2107-75FDFW1/3003,vpath3&lt;BR /&gt;hdisk8,IBM.2107-75FDFW1/3004,vpath4&lt;BR /&gt;hdisk9,IBM.2107-75FDFW1/3005,vpath5&lt;BR /&gt;hdisk10,IBM.2107-75FDFW1/3006,vpath6&lt;BR /&gt;hdisk11,IBM.2107-75FDFW1/3007,vpath7&lt;BR /&gt;hdisk12,IBM.2107-75FDFW1/3008,vpath8&lt;BR /&gt;hdisk13,IBM.2107-75FDFW1/3009,vpath9&lt;BR /&gt;hdisk14,IBM.2107-75FDFW1/3100,vpath10&lt;BR /&gt;hdisk15,IBM.2107-75FDFW1/3101,vpath11&lt;BR /&gt;hdisk16,IBM.2107-75FDFW1/3102,vpath12&lt;BR /&gt;hdisk17,IBM.2107-75FDFW1/3103,vpath13&lt;BR /&gt;hdisk18,IBM.2107-75FDFW1/3104,vpath14&lt;BR /&gt;hdisk19,IBM.2107-75FDFW1/3105,vpath15&lt;BR /&gt;hdisk20,IBM.2107-75FDFW1/3106,vpath16&lt;BR /&gt;hdisk21,IBM.2107-75FDFW1/3107,vpath17&lt;BR /&gt;hdisk22,IBM.2107-75FDFW1/3108,vpath18&lt;BR /&gt;hdisk95,hdisk105,IBM.2107-75FDFW1/1102,vpath47&lt;BR /&gt;hdisk96,hdisk106,IBM.2107-75FDFW1/1103,vpath48&lt;BR /&gt;hdisk100,hdisk141,IBM.2107-75FDFW1/1104,vpath49&lt;BR /&gt;&lt;BR /&gt;I am still messing about with the suggestions above so will keep you updated.&lt;BR /&gt;&lt;BR /&gt;thanks all.&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 09 Oct 2007 03:50:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072993#M92259</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-10-09T03:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072994#M92260</link>
      <description>&amp;gt;here is the sample form each file:&lt;BR /&gt;&amp;gt;paceds.lsfbvol.out:==========================================&lt;BR /&gt;olas_0_1000,1000,Online,Normal,Normal,2107-900,FB 512,P0,36.0,-,75497472&lt;BR /&gt;&amp;gt;$2 being the lun id&lt;BR /&gt;&lt;BR /&gt;&amp;gt;from the file searched where the lun id does not exist:&lt;BR /&gt;&amp;gt;paceds.lshostvol.out&lt;BR /&gt;hdisk4,IBM.2107-75FDFW1/3000,vpath0&lt;BR /&gt;&lt;BR /&gt;I don't see any matches.  Can you provide at least one in the second file?  Since there aren't any, I don't know what "field" I should be looking at?  After the "/"?&lt;BR /&gt;And you seem to have more comma separated fields on the last three.&lt;BR /&gt;&lt;BR /&gt;And if a LUN in the first is in the second, you want to print out that line in the first or second?  (You seemed to have said first in your initial question.)</description>
      <pubDate>Tue, 09 Oct 2007 04:18:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072994#M92260</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-09T04:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072995#M92261</link>
      <description>Thanks Dennis,&lt;BR /&gt;&lt;BR /&gt;I will close this post down now as I will carry on with my notes and repost the question when I have more of an idea - I have seen the "/" in the latter fields so need to work out how to negate that.&lt;BR /&gt;&lt;BR /&gt;Thanks all for your help&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Tue, 09 Oct 2007 05:02:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072995#M92261</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-10-09T05:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072996#M92262</link>
      <description>&amp;gt;I have seen the "/" in the latter fields so need to work out how to negate that.&lt;BR /&gt;&lt;BR /&gt;Not a problem.  Just use index to search $0 for the first "/", then find the next ",".  I.e. don't use any fields at all and make your own.&lt;BR /&gt;Or use FS=/ and scan $2 for the next ",".  Or any combination.  :-)</description>
      <pubDate>Tue, 09 Oct 2007 05:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072996#M92262</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-09T05:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: awk printing</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072997#M92263</link>
      <description>thanks dennis - although I am a bit late with the points</description>
      <pubDate>Wed, 24 Oct 2007 06:03:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-printing/m-p/5072997#M92263</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-10-24T06:03:38Z</dc:date>
    </item>
  </channel>
</rss>

