<?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: Help for script... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810408#M84149</link>
    <description>If you have perl (which all admins should have)-&lt;BR /&gt;&lt;BR /&gt;perl -ne '/^Medium/ &amp;amp;&amp;amp; print((split("[\\[\\]]",$a))[1]);'&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;perl -ne '/^Medium\s*:\s*\[(.*)\]/ &amp;amp;&amp;amp; print $1'&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 20 Sep 2002 13:07:58 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2002-09-20T13:07:58Z</dc:date>
    <item>
      <title>Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810402#M84143</link>
      <description>Hi everyone,&lt;BR /&gt;I need to get a tape id from an output file.&lt;BR /&gt;In the output file I have a line like this:&lt;BR /&gt;Medium :  [9d1c8029:3d888e10:0f0b:0001]&lt;BR /&gt;&lt;BR /&gt;How can I "grep" only the code between the squares?&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt;PSS</description>
      <pubDate>Fri, 20 Sep 2002 12:13:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810402#M84143</guid>
      <dc:creator>PSS SYS ADMIN</dc:creator>
      <dc:date>2002-09-20T12:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810403#M84144</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;grep "^Medium" output_file | awk -F\[ '{print $2}' | awk -F\] '{print $1}'&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;Have a fun day!&lt;BR /&gt;Larry&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 12:18:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810403#M84144</guid>
      <dc:creator>Larry Reinhart</dc:creator>
      <dc:date>2002-09-20T12:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810404#M84145</link>
      <description>You don't. Grep doesn't "extract" strings, it matches on strings!&lt;BR /&gt;&lt;BR /&gt;You need to use something like awk, perl, sed, ...&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(Medium : \[\)\(.*\)\(\]$\)/\2/"&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 20 Sep 2002 12:19:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810404#M84145</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-20T12:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810405#M84146</link>
      <description>You could use sed:-&lt;BR /&gt;&lt;BR /&gt;ID=$(&lt;WHATEVER&gt; | sed -e 's/.*\['// -e 's/].*//') &lt;BR /&gt;&lt;BR /&gt;This removes all text up to the first [ and after the final ].&lt;BR /&gt;&lt;BR /&gt;You could also use the shell itself:-&lt;BR /&gt;&lt;BR /&gt;&lt;WHATEVER&gt; | read DATA&lt;BR /&gt;DATA=${DATA#*\[} # remove text up to the first [&lt;BR /&gt;ID=${DATA%]} #remove the final ] and all after it&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;/WHATEVER&gt;&lt;/WHATEVER&gt;</description>
      <pubDate>Fri, 20 Sep 2002 12:22:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810405#M84146</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-09-20T12:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810406#M84147</link>
      <description>Here's 1 way:&lt;BR /&gt;&lt;BR /&gt;grep Medium "output file" | awk -F[ '{print $2}'  |awk -F] '{print $1}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 12:32:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810406#M84147</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2002-09-20T12:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810407#M84148</link>
      <description>So basicly you use grep to extract the LINE out of the file, then sed to EXTRACT the STRING:&lt;BR /&gt;&lt;BR /&gt;cat thatoutputfilename | &lt;BR /&gt;grep "^Medium " | &lt;BR /&gt;sed "s/^\(Medium : \[\)\(.*\)\(\]$\)/\2/"&lt;BR /&gt;&lt;BR /&gt;returns:&lt;BR /&gt;&lt;BR /&gt;9d1c8029:3d888e10:0f0b:0001&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 20 Sep 2002 12:32:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810407#M84148</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-20T12:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help for script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810408#M84149</link>
      <description>If you have perl (which all admins should have)-&lt;BR /&gt;&lt;BR /&gt;perl -ne '/^Medium/ &amp;amp;&amp;amp; print((split("[\\[\\]]",$a))[1]);'&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;perl -ne '/^Medium\s*:\s*\[(.*)\]/ &amp;amp;&amp;amp; print $1'&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 13:07:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-for-script/m-p/2810408#M84149</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-09-20T13:07:58Z</dc:date>
    </item>
  </channel>
</rss>

