<?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: Script ideas?? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249221#M175076</link>
    <description>I might suggest a start.&lt;BR /&gt;&lt;BR /&gt;awk using [ and or ] to strip the data into a variable&lt;BR /&gt;&lt;BR /&gt;var1=$(awk[ 'print $1')&lt;BR /&gt;&lt;BR /&gt;This is just a course of action, the code doesn't work.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
    <pubDate>Thu, 15 Apr 2004 10:14:15 GMT</pubDate>
    <dc:creator>Steven E. Protter</dc:creator>
    <dc:date>2004-04-15T10:14:15Z</dc:date>
    <item>
      <title>Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249220#M175075</link>
      <description>I need to extract information from lines in a file that are contained within any number of square brackets...&lt;BR /&gt;&lt;BR /&gt;i.e. INPUT      returns     OUTPUT&lt;BR /&gt;XXXXX[A]XXXXX    returns    A&lt;BR /&gt;XYXYX[ABC]XYX    returns    ABC&lt;BR /&gt;ZXCZX[A][B]ZC    returns    AB &lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;Does anyone have any ideas please....&lt;BR /&gt;Cheers&lt;BR /&gt;Russ</description>
      <pubDate>Thu, 15 Apr 2004 10:01:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249220#M175075</guid>
      <dc:creator>Russ Hancock_1</dc:creator>
      <dc:date>2004-04-15T10:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249221#M175076</link>
      <description>I might suggest a start.&lt;BR /&gt;&lt;BR /&gt;awk using [ and or ] to strip the data into a variable&lt;BR /&gt;&lt;BR /&gt;var1=$(awk[ 'print $1')&lt;BR /&gt;&lt;BR /&gt;This is just a course of action, the code doesn't work.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 15 Apr 2004 10:14:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249221#M175076</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-04-15T10:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249222#M175077</link>
      <description># perl -nle'@x=/\[([^]]*)\]/g and print@x' file&lt;BR /&gt;A&lt;BR /&gt;ABC&lt;BR /&gt;AB&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 15 Apr 2004 10:19:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249222#M175077</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-04-15T10:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249223#M175078</link>
      <description>cat input_your_file|tr "\[" ":"|tr "\]" ":"|awk -F : '{print $2}'&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 15 Apr 2004 10:19:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249223#M175078</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-04-15T10:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249224#M175079</link>
      <description>RAC, that will only print the first instance in each line&lt;BR /&gt;&lt;BR /&gt;and it also uses cat where absolutely not neccecary. Useless waste of process space. Use input redirection instead:&lt;BR /&gt;&lt;BR /&gt;NOT # cat file | process&lt;BR /&gt;BUT # process &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 15 Apr 2004 10:24:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249224#M175079</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-04-15T10:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249225#M175080</link>
      <description>Create a file called s.awk and put this into it:&lt;BR /&gt;&lt;BR /&gt;{usestring=$0;printstring="";&lt;BR /&gt; for (idx1=1;idx1&lt;LENGTH&gt;&lt;/LENGTH&gt;   { usestring=substr(usestring,idx1);&lt;BR /&gt;    check1=index(usestring,"[");&lt;BR /&gt;    check2=index(usestring,"]");&lt;BR /&gt;    if (check1&amp;gt;0)&lt;BR /&gt;      {use2=substr(usestring,check1+1,check2-check1-1);&lt;BR /&gt;       printstring=printstring use2; idx1=check2+1;&lt;BR /&gt;      }&lt;BR /&gt;    else&lt;BR /&gt;      {idx1=length($0);}&lt;BR /&gt;   }&lt;BR /&gt;  print printstring;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Then run:&lt;BR /&gt;&lt;BR /&gt;awk -f s.awk &amp;lt; input &amp;gt; output&lt;BR /&gt;&lt;BR /&gt;I'm sure I could stream line it, but it will work as it is now.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Apr 2004 10:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249225#M175080</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2004-04-15T10:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249226#M175081</link>
      <description>Thanks procura.&lt;BR /&gt;&lt;BR /&gt;I am learing perl from gurus like you.&lt;BR /&gt;&lt;BR /&gt;And yes car=t was required. I did not give that much thought to it. Was very fast.&lt;BR /&gt;&lt;BR /&gt;anil</description>
      <pubDate>Thu, 15 Apr 2004 10:33:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249226#M175081</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-04-15T10:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249227#M175082</link>
      <description>Cannot compete with Merijn, but an awk solution :&lt;BR /&gt;&lt;BR /&gt;awk '{&lt;BR /&gt;i2=index($0,"]");&lt;BR /&gt;str=$0;&lt;BR /&gt;while(i2 &amp;gt; 0) {&lt;BR /&gt;  i1=index(str,"[");&lt;BR /&gt;  printf("%s",substr(str,i1 + 1,i2 - i1 -1));&lt;BR /&gt;  str=substr(str,i2 + 1, length(str));&lt;BR /&gt;  i2=index(str,"]");&lt;BR /&gt;} &lt;BR /&gt;printf("\n");&lt;BR /&gt;} '  &lt;YOUR input="" file=""&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc&lt;/YOUR&gt;</description>
      <pubDate>Thu, 15 Apr 2004 11:05:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249227#M175082</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-04-15T11:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249228#M175083</link>
      <description>Thanks Jean-Luc I used your script...</description>
      <pubDate>Fri, 16 Apr 2004 02:30:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249228#M175083</guid>
      <dc:creator>Russ Hancock_1</dc:creator>
      <dc:date>2004-04-16T02:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249229#M175084</link>
      <description>May I ask why you prefer the use several lines of unmaintainable code over a very short and easy perl line of code?&lt;BR /&gt;&lt;BR /&gt;Do you need explaining of any part?&lt;BR /&gt;&lt;BR /&gt;In the original part you did not state what script language you wanted.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 16 Apr 2004 02:42:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249229#M175084</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-04-16T02:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249230#M175085</link>
      <description>There is more to it... Jean-Luc's code will fail if you have lines containing closing square brackets, but without opening brackets, you will get those lines too.&lt;BR /&gt;&lt;BR /&gt;But if are sure the brackets are always matched, you could also do it this way:&lt;BR /&gt;&lt;BR /&gt;awk '/\[/ { sub("^[^\[]*\[","");&lt;BR /&gt;sub("\][^\[]*$","");&lt;BR /&gt;sub("\][^\[]*\[","");&lt;BR /&gt;print&lt;BR /&gt;}' &lt;INPUT /&gt;&lt;BR /&gt;Same could be done with sed and some replacements using sed.</description>
      <pubDate>Fri, 16 Apr 2004 04:02:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249230#M175085</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-04-16T04:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249231#M175086</link>
      <description>Sorry, forgot one char/thing... Last sub should be a gsub, because you can have more then 2 blocks in square brackets.&lt;BR /&gt;&lt;BR /&gt;But I still think Procura's solution is better and on large files faster.</description>
      <pubDate>Fri, 16 Apr 2004 04:07:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249231#M175086</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-04-16T04:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249232#M175087</link>
      <description>Elmar,&lt;BR /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;There is more to it... Jean-Luc's code will fail if you have lines containing closing square brackets, but without opening brackets, you will get those lines too.&lt;BR /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;The code is based on the sample from the poster.&lt;BR /&gt;&lt;BR /&gt;Merijn,&lt;BR /&gt;No offence, I don't think my code is unmaintainable. Certainly, it takes more than one line, and if don't speak perl, that's where you cannot maintain it , would you agree ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Apr 2004 04:08:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249232#M175087</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-04-16T04:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script ideas??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249233#M175088</link>
      <description>Jean-Luc, no offence at all, and sure, it is maintainable, but so verbose that typo's are just a matter of time.&lt;BR /&gt;&lt;BR /&gt;IMHO my perl solution is sooooo darn simple that it just is the best solution. No offence to anyone, and I know I sometimes post rather obfuscated solutions, but this one is so simple that I cannot understand why someone would choose any other solution.&lt;BR /&gt;&lt;BR /&gt;There is a right tool for every problem, and I'm not stating that tool is Perl all the time, but here it outperforms any other in simplicity and shortness&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 16 Apr 2004 04:26:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-ideas/m-p/3249233#M175088</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-04-16T04:26:25Z</dc:date>
    </item>
  </channel>
</rss>

