<?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: Parse text in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589001#M857282</link>
    <description>cat file | awk -F[\(\)] '{print $2;}'</description>
    <pubDate>Wed, 03 Oct 2001 16:07:28 GMT</pubDate>
    <dc:creator>Curtis Larson_1</dc:creator>
    <dc:date>2001-10-03T16:07:28Z</dc:date>
    <item>
      <title>Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588991#M857272</link>
      <description>Can anyone tell me how to return text from a log file leaving certain characters out.&lt;BR /&gt;&lt;BR /&gt;Example Log File&lt;BR /&gt;abcd aa abcd (xxxx)&lt;BR /&gt;&lt;BR /&gt;What I want to return from this entry in the log using a script is &lt;BR /&gt;xxxx&lt;BR /&gt;&lt;BR /&gt;I don't want the parenthesis.  I have been trying to do this using an awk statement, but I seem to be leaving something out.&lt;BR /&gt;&lt;BR /&gt;All help is appreciated&lt;BR /&gt;Thanks&lt;BR /&gt;Jeff</description>
      <pubDate>Wed, 03 Oct 2001 12:42:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588991#M857272</guid>
      <dc:creator>Jeff Paciolla_1</dc:creator>
      <dc:date>2001-10-03T12:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588992#M857273</link>
      <description>Jeff,&lt;BR /&gt;&lt;BR /&gt;Have you tried to use single quotes?&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;&lt;BR /&gt;Pieter</description>
      <pubDate>Wed, 03 Oct 2001 12:46:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588992#M857273</guid>
      <dc:creator>Van de Wygaert Pieter</dc:creator>
      <dc:date>2001-10-03T12:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588993#M857274</link>
      <description>i am not sure exactly what you mean by using single quotes, but I will provide a little info about the log file.  It comes to me when an event takes places in my NNM network.  I have no control over the format of the text message so I can't change the look.  I just have to grab the info inside the ()&lt;BR /&gt;&lt;BR /&gt;Thanks for your help</description>
      <pubDate>Wed, 03 Oct 2001 12:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588993#M857274</guid>
      <dc:creator>Jeff Paciolla_1</dc:creator>
      <dc:date>2001-10-03T12:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588994#M857275</link>
      <description>Greetings Jeff,&lt;BR /&gt;&lt;BR /&gt;  This pipeline is one way to do it :&lt;BR /&gt;&lt;BR /&gt;cat logfile | tr -d "()" | awk '{ print $4 }'&lt;BR /&gt;&lt;BR /&gt;  The "tr -d" deletes whatever characters are between the double quotes.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Bruce&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Oct 2001 13:08:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588994#M857275</guid>
      <dc:creator>Bruce Bush</dc:creator>
      <dc:date>2001-10-03T13:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588995#M857276</link>
      <description>Hi Jeff:&lt;BR /&gt;&lt;BR /&gt;Create an awk script like this one (I've intentionally made it more verbose than necessary for clarity) called my.awk:&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;  n1 = index($0,"(")&lt;BR /&gt;  if (n1 &amp;gt; 0)&lt;BR /&gt;    {&lt;BR /&gt;      n2 = index($0,")")&lt;BR /&gt;      if (n2 &amp;gt; n1)&lt;BR /&gt;        {&lt;BR /&gt;          s = substr($0,n1 + 1,n2 - n1 -1)&lt;BR /&gt;          printf("%s\n",s)&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;cat yourfile | awk -f my.awk&lt;BR /&gt;&lt;BR /&gt;That should do it, Clay</description>
      <pubDate>Wed, 03 Oct 2001 13:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588995#M857276</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-10-03T13:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588996#M857277</link>
      <description>Hi Jeff,&lt;BR /&gt;You could do it with:&lt;BR /&gt;&lt;BR /&gt;root:L1000&amp;gt;:awk '{print $3}' test | sed 's/)//g' | sed 's/(//g' &amp;gt; final&lt;BR /&gt;&lt;BR /&gt;probably prettier ways to do it, but this would be quick....&lt;BR /&gt;RD</description>
      <pubDate>Wed, 03 Oct 2001 13:20:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588996#M857277</guid>
      <dc:creator>Richard Darling</dc:creator>
      <dc:date>2001-10-03T13:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588997#M857278</link>
      <description>Jeff, "test" would be your logfile...&lt;BR /&gt;RD</description>
      <pubDate>Wed, 03 Oct 2001 13:21:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588997#M857278</guid>
      <dc:creator>Richard Darling</dc:creator>
      <dc:date>2001-10-03T13:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588998#M857279</link>
      <description>Hi Jeff,&lt;BR /&gt;&lt;BR /&gt;  Yet another variation in awk would be...&lt;BR /&gt;&lt;BR /&gt;cat logfile | awk '{ sub(/\(/, ""); sub(/\)/, ""); print $4 }'&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Bruce</description>
      <pubDate>Wed, 03 Oct 2001 13:27:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588998#M857279</guid>
      <dc:creator>Bruce Bush</dc:creator>
      <dc:date>2001-10-03T13:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588999#M857280</link>
      <description>Hi Jeff,&lt;BR /&gt;&lt;BR /&gt;Using sed:&lt;BR /&gt;&lt;BR /&gt;$ echo 'abcd aa abcd (xxxx)' | sed 's/.*(\(.*\)).*/\1/'&lt;BR /&gt;xxxx&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Wed, 03 Oct 2001 13:45:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2588999#M857280</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-10-03T13:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589000#M857281</link>
      <description>Thanks to everybody that replied, I decided on going with the sed command. It worked great.&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Wed, 03 Oct 2001 14:24:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589000#M857281</guid>
      <dc:creator>Jeff Paciolla_1</dc:creator>
      <dc:date>2001-10-03T14:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589001#M857282</link>
      <description>cat file | awk -F[\(\)] '{print $2;}'</description>
      <pubDate>Wed, 03 Oct 2001 16:07:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589001#M857282</guid>
      <dc:creator>Curtis Larson_1</dc:creator>
      <dc:date>2001-10-03T16:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589002#M857283</link>
      <description>Now if all the lines aren't formated as stated:&lt;BR /&gt;&lt;BR /&gt;you'll probably have to add a NF&amp;gt;2 as in&lt;BR /&gt;'NF&amp;gt;2 {print $2;}'&lt;BR /&gt;&lt;BR /&gt;this still doesn't in sure that there is a  ( ) pair.  i.e. two ) or two ( on a line will still generate output.  For this situation I'd use the sed suggestion also because it matches a more "exact" pattern. i.e. a () pair.  Although it will only output the pattern in the last () pair on a line if there is more then one.</description>
      <pubDate>Wed, 03 Oct 2001 16:27:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589002#M857283</guid>
      <dc:creator>Curtis Larson_1</dc:creator>
      <dc:date>2001-10-03T16:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589003#M857284</link>
      <description>Hi Jeff,&lt;BR /&gt;&lt;BR /&gt;My reply was for processing a single line.  For processing files, use:&lt;BR /&gt;&lt;BR /&gt;sed -n 's/.*(\(.*\)).*/\1/p' file&lt;BR /&gt;&lt;BR /&gt;to *only* display the bracketed contents within the file.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 04 Oct 2001 06:20:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589003#M857284</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-10-04T06:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589004#M857285</link>
      <description>i appreciate everybody's help on this issue.  Just one more question, shouldn't I be able to do the same thing with a NNM variable as opposed to a logfile.&lt;BR /&gt;Example:&lt;BR /&gt;instead of logfile being&lt;BR /&gt;abcd aa abcd (xxxx)&lt;BR /&gt;what if&lt;BR /&gt;$1 from a NNM alert was&lt;BR /&gt;&lt;BR /&gt;abcd aa abcd (xxxx)&lt;BR /&gt;&lt;BR /&gt;Could I do something like this&lt;BR /&gt;&lt;BR /&gt;Test=$1 | `awk '{print $4}'`&lt;BR /&gt;&lt;BR /&gt;Where I want to set variable Test equal to xxxx&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jeff&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Oct 2001 15:01:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589004#M857285</guid>
      <dc:creator>Jeff Paciolla_1</dc:creator>
      <dc:date>2001-10-04T15:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589005#M857286</link>
      <description>Hi Jeff:&lt;BR /&gt;&lt;BR /&gt;# X=`echo "abcd aa abcd (xxxx)"|awk '{print $4}'`&lt;BR /&gt;# echo $X&lt;BR /&gt;&lt;BR /&gt;...would yield "(xxxx)"&lt;BR /&gt;&lt;BR /&gt;Similarly, leveraging Robin's first solution:&lt;BR /&gt;&lt;BR /&gt;# Y=`echo 'abcd aa abcd (xxxx)' | sed 's/.*(\(.*\)).*/\1/'`&lt;BR /&gt;# echo $Y&lt;BR /&gt;&lt;BR /&gt;...would yield "xxxx"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 04 Oct 2001 15:22:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589005#M857286</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-10-04T15:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: Parse text in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589006#M857287</link>
      <description>Thanks James that worked perfectly&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Thu, 04 Oct 2001 15:38:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-text-in-script/m-p/2589006#M857287</guid>
      <dc:creator>Jeff Paciolla_1</dc:creator>
      <dc:date>2001-10-04T15:38:25Z</dc:date>
    </item>
  </channel>
</rss>

