<?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: Pattern matching for variables within a korn shell program in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663062#M48837</link>
    <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;you have also a second way to set a value to a variable: ( this is called command substitution )&lt;BR /&gt;&lt;BR /&gt;var=`pwd`   # these are back- ticks, this syntax will be understood by all shells, even the Bourne- shell accepts it&lt;BR /&gt;&lt;BR /&gt;var=$(pwd) # this syntax can be used for ksh and POSIX shell&lt;BR /&gt;&lt;BR /&gt;# pwd&lt;BR /&gt;/home/peter&lt;BR /&gt;&lt;BR /&gt;# var=`pwd`&lt;BR /&gt;&lt;BR /&gt;# echo $var | grep 'peter'&lt;BR /&gt;/home/peter&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
    <pubDate>Tue, 12 Feb 2002 12:18:08 GMT</pubDate>
    <dc:creator>Peter Kloetgen</dc:creator>
    <dc:date>2002-02-12T12:18:08Z</dc:date>
    <item>
      <title>Pattern matching for variables within a korn shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663058#M48833</link>
      <description>All I want to do is use regular expression type&lt;BR /&gt;pattern match testing in a korn shell script to test a variable.&lt;BR /&gt;&lt;BR /&gt;Put another way,&lt;BR /&gt;Is pattern matching only available for use on lines in a file (with utils like sed, grep awk etc) or can I use it on a variable in a script file?</description>
      <pubDate>Tue, 12 Feb 2002 11:42:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663058#M48833</guid>
      <dc:creator>Mr Peter Kempner</dc:creator>
      <dc:date>2002-02-12T11:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern matching for variables within a korn shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663059#M48834</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Just echo the variable through a pipe, e.g.&lt;BR /&gt;&lt;BR /&gt;# VAR=hello&lt;BR /&gt;# echo $VAR | grep "el"&lt;BR /&gt;hello&lt;BR /&gt;# echo $VAR | sed 's/e/u/'&lt;BR /&gt;hullo&lt;BR /&gt;# echo $VAR | awk '{print substr($0,2,3)}'&lt;BR /&gt;ell&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Tue, 12 Feb 2002 11:48:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663059#M48834</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-02-12T11:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern matching for variables within a korn shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663060#M48835</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Extended pattern matching is  available in the shell for if and case statements etc.&lt;BR /&gt;&lt;BR /&gt;Excerpt from 'man sh-posix':-&lt;BR /&gt;&lt;BR /&gt;In addition to the notation described in regexp(5), sh recognizes composite patterns made up of one or more pattern lists separated from&lt;BR /&gt;each other with a |.  Composite patterns can be formed with one or more of the following:&lt;BR /&gt;&lt;BR /&gt;     ?(pattern-list)   Matches any one of the given patterns.&lt;BR /&gt;     *(pattern-list)   Matches zero or more occurrences of the given&lt;BR /&gt;                       patterns.&lt;BR /&gt;     +(pattern-list)   Matches one or more occurrences of the given&lt;BR /&gt;                       patterns.&lt;BR /&gt;     @(pattern-list)   Matches exactly one of the given patterns.&lt;BR /&gt;     !(pattern-list)   Matches anything, except one of the given&lt;BR /&gt;                       patterns.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Tue, 12 Feb 2002 12:02:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663060#M48835</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-02-12T12:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern matching for variables within a korn shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663061#M48836</link>
      <description>I should also have mentioned that it's much more efficient to use the shell's built in features rather than having to fork a new process (like grep).&lt;BR /&gt;&lt;BR /&gt;For instance:&lt;BR /&gt;VAR=hello&lt;BR /&gt;echo $VAR|grep "el"&lt;BR /&gt;&lt;BR /&gt;could be done internally with:&lt;BR /&gt;if [[ ${VAR} = *el* ]];&lt;BR /&gt;then...&lt;BR /&gt;&lt;BR /&gt;or using an example of the shell extensions:&lt;BR /&gt;if [[ ${VAR} = *(?)el*(?) ]];&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Tue, 12 Feb 2002 12:09:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663061#M48836</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-02-12T12:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern matching for variables within a korn shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663062#M48837</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;you have also a second way to set a value to a variable: ( this is called command substitution )&lt;BR /&gt;&lt;BR /&gt;var=`pwd`   # these are back- ticks, this syntax will be understood by all shells, even the Bourne- shell accepts it&lt;BR /&gt;&lt;BR /&gt;var=$(pwd) # this syntax can be used for ksh and POSIX shell&lt;BR /&gt;&lt;BR /&gt;# pwd&lt;BR /&gt;/home/peter&lt;BR /&gt;&lt;BR /&gt;# var=`pwd`&lt;BR /&gt;&lt;BR /&gt;# echo $var | grep 'peter'&lt;BR /&gt;/home/peter&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Tue, 12 Feb 2002 12:18:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-matching-for-variables-within-a-korn-shell-program/m-p/2663062#M48837</guid>
      <dc:creator>Peter Kloetgen</dc:creator>
      <dc:date>2002-02-12T12:18:08Z</dc:date>
    </item>
  </channel>
</rss>

