<?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:  Filtering certain fields and data. ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096716#M311263</link>
    <description>and one of many obligatory perl alternatives....&lt;BR /&gt;&lt;BR /&gt;$ perl -ne 'while (/\b(c\S+B)\b/) {print qq($1\n);$_=$'"'}" filename&lt;BR /&gt;&lt;BR /&gt;This is a double loop, the -n looping over the records.&lt;BR /&gt;The a loop looking for:&lt;BR /&gt;\b = a word boundary&lt;BR /&gt;(  = start remembering&lt;BR /&gt;c&lt;BR /&gt;\S+ a series of 1 or more non-whitespace&lt;BR /&gt;B&lt;BR /&gt;) = stop remembering&lt;BR /&gt;\b a word boundary&lt;BR /&gt;&lt;BR /&gt;If matched, print the remembered part and make the default variable $_ become the 'post-match' remainder of the line.&lt;BR /&gt;The is expressed with $'&lt;BR /&gt;Of course the ' fights with the initial '&lt;BR /&gt;One way to solve that is a terminate the 'program' string and open a new "rest" string with the '. Ugly.&lt;BR /&gt;There are alternatives, and this problem does not exist for a program in a script. It is a command line thing.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 03 Nov 2007 08:43:14 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2007-11-03T08:43:14Z</dc:date>
    <item>
      <title>scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096711#M311258</link>
      <description>Hi Experts,&lt;BR /&gt;&lt;BR /&gt;Here is the data file:&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;0769 021E  c4t3d3/14A c9t3d3/08B c11t3d3/09A c17t3d3/03B&lt;BR /&gt;0769 0256  c4t4d2/14A c9t4d2/08B c11t4d2/09A c17t4d2/03B&lt;BR /&gt;0769 0296  c4t5d2/14A c9t5d2/08B c11t5d2/09A c17t5d2/03B&lt;BR /&gt;0769 0326  c4t7d4/14A c9t7d4/08B c11t7d4/09A c17t7d4/03B&lt;BR /&gt;0769 0356  c4t8d2/14A c9t8d2/08B c11t8d2/09A c17t8d2/03B&lt;BR /&gt;0769 03DE  c4t10d3/14A c9t10d3/08B c11t10d3/09A c17t10d3/03B&lt;BR /&gt;0769 042E  c4t11d5/14A c9t11d5/08B c11t11d5/09A c17t11d5/03B&lt;BR /&gt;0769 048E  c4t13d1/14A c9t13d1/08B c11t13d1/09A c17t13d1/03B&lt;BR /&gt;0769 04D6  c4t14d2/14A c9t14d2/08B c11t14d2/09A c17t14d2/03B&lt;BR /&gt;0769 05A6  c19t1d0/09A c20t1d0/08B c21t1d0/14A c22t1d0/03B&lt;BR /&gt;0769 05C6  c19t1d4/09A c20t1d4/08B c21t1d4/14A c22t1d4/03B&lt;BR /&gt;0769 0656  c19t3d6/09A c20t3d6/08B c21t3d6/14A c22t3d6/03B&lt;BR /&gt;0769 06DE  c19t5d7/09A c20t5d7/08B c21t5d7/14A c22t5d7/03B&lt;BR /&gt;0769 06EE  c19t6d1/09A c20t6d1/08B c21t6d1/14A c22t6d1/03B&lt;BR /&gt;0769 071E  c19t6d7/09A c20t6d7/08B c21t6d7/14A c22t6d7/03B&lt;BR /&gt;0769 086E  c19t12d1/09A c20t12d1/08B c21t12d1/14A c22t12d1/03B&lt;BR /&gt;0769 087E  c19t12d3/09A c20t12d3/08B c21t12d3/14A c22t12d3/03B&lt;BR /&gt;0769 08AE  c19t13d1/09A c20t13d1/08B c21t13d1/14A c22t13d1/03B&lt;BR /&gt;0769 0926  c24t14d6/14A c25t14d6/03B c26t14d6/08B c27t14d6/09A&lt;BR /&gt;0769 093E  c24t15d1/14A c25t15d1/03B c26t15d1/08B c27t15d1/09A&lt;BR /&gt;0769 0A06  c24t2d0/14A c25t2d0/03B c26t2d0/08B c27t2d0/09A&lt;BR /&gt;0769 0A66  c24t3d4/14A c25t3d4/03B c26t3d4/08B c27t3d4/09A&lt;BR /&gt;0769 0A86  c24t4d0/14A c25t4d0/03B c26t4d0/08B c27t4d0/09A&lt;BR /&gt;0769 0AAE  c24t4d5/14A c25t4d5/03B c26t4d5/08B c27t4d5/09A&lt;BR /&gt;0769 0AC6  c24t5d0/14A c25t5d0/03B c26t5d0/08B c27t5d0/09A&lt;BR /&gt;0769 0AD6  c24t5d2/14A c25t5d2/03B c26t5d2/08B c27t5d2/09A&lt;BR /&gt;0769 0C9E  c24t12d3/14A c25t12d3/03B c26t12d3/08B c27t12d3/09A&lt;BR /&gt;0769 140E  c41t1d1/08B c42t1d1/09A c43t1d1/14A c44t1d1/03B&lt;BR /&gt;0769 141E  c41t1d2/08B c42t1d2/09A c43t1d2/14A c44t1d2/03B&lt;BR /&gt;0769 1426  c41t1d3/08B c42t1d3/09A c43t1d3/14A c44t1d3/03B&lt;BR /&gt;0769 1436  c41t1d4/08B c42t1d4/09A c43t1d4/14A c44t1d4/03B&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to filter all the devices ending with 'B' ( example: c9t3d3/08B ) and need to produce a single file with all the  'B' devices one after another in a column format. &lt;BR /&gt;&lt;BR /&gt;The file attached to view in the proper format:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The output should be look like this: &lt;BR /&gt;c41t1d2/08B &lt;BR /&gt;c41t1d4/08B&lt;BR /&gt;c25t12d3/03B&lt;BR /&gt;c25t5d2/03B &lt;BR /&gt;...  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please suggest how to do it with the help of a script,&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2007 00:57:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096711#M311258</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2007-11-03T00:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096712#M311259</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Since your starting character is 'c' and ending is 'B' , you can do the following to get as you wanted.&lt;BR /&gt;&lt;BR /&gt;cat filename |tr ' ' '\n'  |grep '^c'|grep 'B$'&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;RD</description>
      <pubDate>Sat, 03 Nov 2007 01:17:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096712#M311259</guid>
      <dc:creator>rajdev</dc:creator>
      <dc:date>2007-11-03T01:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096713#M311260</link>
      <description>This awk script scans field 3, 4, 5 and 6 and prints that field if it ends in "B".&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN { PAT = "B$" }&lt;BR /&gt;$3 ~ PAT { print $3 }&lt;BR /&gt;$4 ~ PAT { print $4 }&lt;BR /&gt;$5 ~ PAT { print $5 }&lt;BR /&gt;$6 ~ PAT { print $6 }&lt;BR /&gt;' filename&lt;BR /&gt;&lt;BR /&gt;Is there any ordering requirements?</description>
      <pubDate>Sat, 03 Nov 2007 01:20:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096713#M311260</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-03T01:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096714#M311261</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;note: there is a single space in the tr ...&lt;BR /&gt;&lt;BR /&gt;cat filename |tr ' ' '\n'  |grep '^c'|grep 'B$' &amp;gt; filename.out&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;RD</description>
      <pubDate>Sat, 03 Nov 2007 01:31:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096714#M311261</guid>
      <dc:creator>rajdev</dc:creator>
      <dc:date>2007-11-03T01:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096715#M311262</link>
      <description>&amp;gt;RD: cat filename |tr ' ' '\n' |grep '^c'|grep 'B$'&lt;BR /&gt;&lt;BR /&gt;This can be optimized to remove useless cats:&lt;BR /&gt;tr ' ' '\n' &amp;lt; filename | grep '^c.*B$'</description>
      <pubDate>Sat, 03 Nov 2007 01:42:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096715#M311262</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-03T01:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096716#M311263</link>
      <description>and one of many obligatory perl alternatives....&lt;BR /&gt;&lt;BR /&gt;$ perl -ne 'while (/\b(c\S+B)\b/) {print qq($1\n);$_=$'"'}" filename&lt;BR /&gt;&lt;BR /&gt;This is a double loop, the -n looping over the records.&lt;BR /&gt;The a loop looking for:&lt;BR /&gt;\b = a word boundary&lt;BR /&gt;(  = start remembering&lt;BR /&gt;c&lt;BR /&gt;\S+ a series of 1 or more non-whitespace&lt;BR /&gt;B&lt;BR /&gt;) = stop remembering&lt;BR /&gt;\b a word boundary&lt;BR /&gt;&lt;BR /&gt;If matched, print the remembered part and make the default variable $_ become the 'post-match' remainder of the line.&lt;BR /&gt;The is expressed with $'&lt;BR /&gt;Of course the ' fights with the initial '&lt;BR /&gt;One way to solve that is a terminate the 'program' string and open a new "rest" string with the '. Ugly.&lt;BR /&gt;There are alternatives, and this problem does not exist for a program in a script. It is a command line thing.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2007 08:43:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096716#M311263</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-11-03T08:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096717#M311264</link>
      <description>Hi Rveri:&lt;BR /&gt;&lt;BR /&gt;Here's another (TMTOWTDI) Perl:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '{@a=split;print for /c\S+B/g}' file&lt;BR /&gt;&lt;BR /&gt;...This splits each line on whitespace (spaces, tabs, newlines) and looks for strings beginning with a "c" and ending with "B" with at least one non-whitespace (\S+) character between.  For every matching occurance on each line, the matched token is printed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 03 Nov 2007 09:49:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096717#M311264</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-03T09:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096718#M311265</link>
      <description>Hi (again) Rveri:&lt;BR /&gt;&lt;BR /&gt;Ooops, ignore my first post.  I posted a composite of two approaches without sufficient refinement.  Instead, use:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '{print for /\bc\S+B\b/g}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 03 Nov 2007 10:15:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096718#M311265</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-03T10:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096719#M311266</link>
      <description># awk '{for(i=1;i&amp;lt;=NF;++i) if($i~"B$") print $i}' file</description>
      <pubDate>Sat, 03 Nov 2007 11:26:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096719#M311266</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-11-03T11:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096720#M311267</link>
      <description>Awesome scripts! . Thanks. &lt;BR /&gt;I like all the scripts given here : tr, perl , awk and all worked fine. Though one perl script found to be long enough. And the best one found the oneliner one. Thanks all (again!).</description>
      <pubDate>Mon, 05 Nov 2007 22:59:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096720#M311267</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2007-11-05T22:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question:  Filtering certain fields and data. ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096721#M311268</link>
      <description>&amp;gt;And the best one found the oneliner one.&lt;BR /&gt;&lt;BR /&gt;The best one may be the one you can understand and perhaps modify.  (That's why I had the 4 fields.)</description>
      <pubDate>Mon, 05 Nov 2007 23:28:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-filtering-certain-fields-and-data/m-p/4096721#M311268</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-05T23:28:28Z</dc:date>
    </item>
  </channel>
</rss>

