<?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: commands in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897556#M96733</link>
    <description>$  echo :[rosePink]  | awk -F [\]\[] '{ print $2}'&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;Actually, as much as I often think Shiv shoudl use study the man pages a bit more, and just try some stuff to learn, this time he is onto something tricky.&lt;BR /&gt;&lt;BR /&gt;The square brackets are tricky to specify as they are a critical part of regular expression.&lt;BR /&gt;&lt;BR /&gt;As we all know, awk can use a regulare expression as field seperator. And boxed characters are a choicelist of sort. Pick "i" and "o" as seperators and this works...&lt;BR /&gt; &lt;BR /&gt;$  echo :[rosePink]  | awk -F [io] '{ print $2}'&lt;BR /&gt;seP&lt;BR /&gt;&lt;BR /&gt;Now pick "[" and "]"... no go...&lt;BR /&gt;$  echo :[rosePink]  | awk -F [[]] '{ print $2}'&lt;BR /&gt;&lt;BR /&gt;Ok, so escape them.... no go...&lt;BR /&gt;&lt;BR /&gt;$  echo :[rosePink]  | awk -F [\[\]] '{ print $2}'&lt;BR /&gt;&lt;BR /&gt;Now escape them, and re-order and it works:&lt;BR /&gt;&lt;BR /&gt;$  echo :[rosePink]  | awk -F [\]\[] '{ print $2}'&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;At first I though i was battling the shell on top of awk, but even using a tiny awk program you need to take thenm out of order.&lt;BR /&gt;&lt;BR /&gt;$ cat test.awk&lt;BR /&gt;BEGIN { FS="[][]" }&lt;BR /&gt;{ print "1=" $1 " 2=" $2 " 3=" $3 }&lt;BR /&gt;$  echo :[test]aaa  | awk -f x.awk&lt;BR /&gt;1=: 2=test 3=aaa&lt;BR /&gt;&lt;BR /&gt;grins,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
    <pubDate>Mon, 13 Nov 2006 22:23:12 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2006-11-13T22:23:12Z</dc:date>
    <item>
      <title>commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897550#M96727</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;From the below word&lt;BR /&gt; &lt;BR /&gt;:[rosePink]&lt;BR /&gt;&lt;BR /&gt;i want to remove : [,  and ]&lt;BR /&gt;&lt;BR /&gt;i just want to extract rosePink.&lt;BR /&gt;&lt;BR /&gt;How do i do that ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv</description>
      <pubDate>Mon, 13 Nov 2006 20:19:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897550#M96727</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-11-13T20:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897551#M96728</link>
      <description>If you have that word in a file say "aa" then do this&lt;BR /&gt;sed -e 's/:\[//' -e 's/\]//' aa&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2006 20:30:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897551#M96728</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2006-11-13T20:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897552#M96729</link>
      <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;Another way:&lt;BR /&gt;&lt;BR /&gt;# echo "I am :[rosePink] I am" | perl -ne 'print $1 if m%.*\[(.+)\].*%'&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print $1 if m%.*\[(.+)\].*%' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2006 21:09:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897552#M96729</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-11-13T21:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897553#M96730</link>
      <description>we don't want to use the word "i am and also don't want to use perl"..&lt;BR /&gt;&lt;BR /&gt;is there any other alternative using greg/egrep or awk ?&lt;BR /&gt;&lt;BR /&gt;best regards,&lt;BR /&gt;shiv</description>
      <pubDate>Mon, 13 Nov 2006 21:19:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897553#M96730</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-11-13T21:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897554#M96731</link>
      <description>A solution using awk:&lt;BR /&gt;&lt;BR /&gt;echo ":[rosePink]" | awk -F [ '{print $2}' | awk -F ] '{print $1}'</description>
      <pubDate>Mon, 13 Nov 2006 21:27:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897554#M96731</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-11-13T21:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897555#M96732</link>
      <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;You wrote, "we don't want to use the word "i am and also don't want to use perl".&lt;BR /&gt;&lt;BR /&gt;First, the example I showed simply extracts the string contained in square brackets --- which was exactly the extent of what you asked.&lt;BR /&gt;&lt;BR /&gt;Second, you never indicated what tools you would accept and what tools you would not.  Perl was my choice.&lt;BR /&gt;&lt;BR /&gt;# echo ":[rosePink]"|perl -nle 'print $1 if m%\[(.+)\]%' &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2006 21:49:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897555#M96732</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-11-13T21:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897556#M96733</link>
      <description>$  echo :[rosePink]  | awk -F [\]\[] '{ print $2}'&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;Actually, as much as I often think Shiv shoudl use study the man pages a bit more, and just try some stuff to learn, this time he is onto something tricky.&lt;BR /&gt;&lt;BR /&gt;The square brackets are tricky to specify as they are a critical part of regular expression.&lt;BR /&gt;&lt;BR /&gt;As we all know, awk can use a regulare expression as field seperator. And boxed characters are a choicelist of sort. Pick "i" and "o" as seperators and this works...&lt;BR /&gt; &lt;BR /&gt;$  echo :[rosePink]  | awk -F [io] '{ print $2}'&lt;BR /&gt;seP&lt;BR /&gt;&lt;BR /&gt;Now pick "[" and "]"... no go...&lt;BR /&gt;$  echo :[rosePink]  | awk -F [[]] '{ print $2}'&lt;BR /&gt;&lt;BR /&gt;Ok, so escape them.... no go...&lt;BR /&gt;&lt;BR /&gt;$  echo :[rosePink]  | awk -F [\[\]] '{ print $2}'&lt;BR /&gt;&lt;BR /&gt;Now escape them, and re-order and it works:&lt;BR /&gt;&lt;BR /&gt;$  echo :[rosePink]  | awk -F [\]\[] '{ print $2}'&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;At first I though i was battling the shell on top of awk, but even using a tiny awk program you need to take thenm out of order.&lt;BR /&gt;&lt;BR /&gt;$ cat test.awk&lt;BR /&gt;BEGIN { FS="[][]" }&lt;BR /&gt;{ print "1=" $1 " 2=" $2 " 3=" $3 }&lt;BR /&gt;$  echo :[test]aaa  | awk -f x.awk&lt;BR /&gt;1=: 2=test 3=aaa&lt;BR /&gt;&lt;BR /&gt;grins,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2006 22:23:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897556#M96733</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-11-13T22:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897557#M96734</link>
      <description>Hmm,&lt;BR /&gt;&lt;BR /&gt;Shiv wrote&amp;gt; i want to remove : [, and ]&lt;BR /&gt;&lt;BR /&gt;taking that original request literally the solution would be:&lt;BR /&gt;&lt;BR /&gt;$  echo :[rosePink]  | tr -d :[]&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Or with symbols:&lt;BR /&gt;&lt;BR /&gt;$ x=:[rosePink]&lt;BR /&gt;$ y=$(echo $x |  tr -d :[])&lt;BR /&gt;$ echo $x " - " $y&lt;BR /&gt;:[rosePink]  -  rosePink&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2006 22:51:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897557#M96734</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-11-13T22:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897558#M96735</link>
      <description>Thanks James!!&lt;BR /&gt;&lt;BR /&gt;I respect your choice of tools as always.&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Shiv&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Nov 2006 00:45:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897558#M96735</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-11-14T00:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897559#M96736</link>
      <description>Hi Shiv&lt;BR /&gt;this run fine on my Hp-UX11i:&lt;BR /&gt;% echo ":[rosePink]"|tr -d [:punct:]&lt;BR /&gt;rosePink&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 15 Nov 2006 05:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897559#M96736</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-11-15T05:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897560#M96737</link>
      <description>&amp;gt;Arturo: tr -d [:punct:]&lt;BR /&gt;&lt;BR /&gt;Yes, this will work, provided Shivkumar wants to remove ALL punctuation.  White space is left.</description>
      <pubDate>Wed, 15 Nov 2006 06:09:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897560#M96737</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-11-15T06:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: commands</title>
      <link>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897561#M96738</link>
      <description>I believe this will provide a concise solution, without forceably removing all punctuation:&lt;BR /&gt;&lt;BR /&gt;$ echo :[rosePink] | sed 's/:\[\(.*\)\]/\1/'&lt;BR /&gt;rosePink</description>
      <pubDate>Fri, 01 Dec 2006 05:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/commands/m-p/3897561#M96738</guid>
      <dc:creator>Eric Raeburn</dc:creator>
      <dc:date>2006-12-01T05:16:18Z</dc:date>
    </item>
  </channel>
</rss>

