<?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 Question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714843#M61518</link>
    <description>The ${#&lt;PARAMETER&gt;} construct is by far the most efficient because it is evaluated by the shell itself rather than calling a seperate process.&lt;BR /&gt;&lt;BR /&gt;Bear in mind however that it is not valid in the real Bourne shell (/usr/old/bin/sh). You're not using that are you?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PARAMETER&gt;</description>
    <pubDate>Wed, 01 May 2002 13:54:45 GMT</pubDate>
    <dc:creator>John Palmer</dc:creator>
    <dc:date>2002-05-01T13:54:45Z</dc:date>
    <item>
      <title>Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714831#M61506</link>
      <description>Using the Bourne shell is there a command to&lt;BR /&gt;find the length of a string?</description>
      <pubDate>Wed, 01 May 2002 13:32:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714831#M61506</guid>
      <dc:creator>Shannon_1</dc:creator>
      <dc:date>2002-05-01T13:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714832#M61507</link>
      <description>Try-&lt;BR /&gt;&lt;BR /&gt;x="abcdef"&lt;BR /&gt;echo ${#x}&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 01 May 2002 13:34:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714832#M61507</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-05-01T13:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714833#M61508</link>
      <description>Hi.  Try this:  echo $PWD | wc -m</description>
      <pubDate>Wed, 01 May 2002 13:34:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714833#M61508</guid>
      <dc:creator>Jeffrey Davis_1</dc:creator>
      <dc:date>2002-05-01T13:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714834#M61509</link>
      <description>&lt;BR /&gt;#man wc&lt;BR /&gt;&lt;BR /&gt;wc recognizes the following command-line options:&lt;BR /&gt;&lt;BR /&gt;           -c        Write to the standard output the number of bytes in&lt;BR /&gt;                     each input file.&lt;BR /&gt;&lt;BR /&gt;           -m        Write to the standard output the number of characters&lt;BR /&gt;                     in each input file.&lt;BR /&gt;&lt;BR /&gt;           -w        Write to the standard output the number of words in&lt;BR /&gt;                     each input file.&lt;BR /&gt;&lt;BR /&gt;           -l        Write to the standard output the number of newline&lt;BR /&gt;                     characters in each input file.</description>
      <pubDate>Wed, 01 May 2002 13:34:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714834#M61509</guid>
      <dc:creator>Anthony deRito</dc:creator>
      <dc:date>2002-05-01T13:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714835#M61510</link>
      <description>echo $string | wc -c&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 May 2002 13:35:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714835#M61510</guid>
      <dc:creator>Rajeev Tyagi</dc:creator>
      <dc:date>2002-05-01T13:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714836#M61511</link>
      <description>echo "12345" | wc -c &lt;BR /&gt;&lt;BR /&gt;Then minus 1&lt;BR /&gt;</description>
      <pubDate>Wed, 01 May 2002 13:37:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714836#M61511</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2002-05-01T13:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714837#M61512</link>
      <description>Hi Shannon&lt;BR /&gt;&lt;BR /&gt;What about wc -c , where in it counts the no. of bytes in the input .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
      <pubDate>Wed, 01 May 2002 13:39:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714837#M61512</guid>
      <dc:creator>MANOJ SRIVASTAVA</dc:creator>
      <dc:date>2002-05-01T13:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714838#M61513</link>
      <description>Another method:&lt;BR /&gt;&lt;BR /&gt;S1="This is a test"&lt;BR /&gt;LEN=`expr length "${S1}"`&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 May 2002 13:43:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714838#M61513</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-05-01T13:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714839#M61514</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Rodneys method works fine if you mean to use the posix shell (/usr/bin/sh on HP-UX). The *real* bourne shell on HP-UX is in /usr/old/bin/sh. Posix shells aren't available on all flavours of UNIX so if you *really* want to use the bourne shell then the methods using wc will work fine - but remember that wc will include the new line from the echo command in the output so you will always get the length of your string plus one unless you tell echo not to include the newline:&lt;BR /&gt;&lt;BR /&gt;# /usr/old/bin/sh&lt;BR /&gt;# x="1234"&lt;BR /&gt;# echo ${#x}&lt;BR /&gt;bad substitution&lt;BR /&gt;# exit&lt;BR /&gt;&lt;BR /&gt;# x="1234"&lt;BR /&gt;# echo ${#x}&lt;BR /&gt;4&lt;BR /&gt;# echo $x | wc -m&lt;BR /&gt;5&lt;BR /&gt;# echo "$x\c" | wc -m&lt;BR /&gt;4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Wed, 01 May 2002 13:46:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714839#M61514</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2002-05-01T13:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714840#M61515</link>
      <description>Duncan's answer is correct.&lt;BR /&gt;&lt;BR /&gt;I bad.&lt;BR /&gt;&lt;BR /&gt;I started /usr/bin/sh and forgot it was posix.&lt;BR /&gt;&lt;BR /&gt;Good call Duncan...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 01 May 2002 13:49:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714840#M61515</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-05-01T13:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714841#M61516</link>
      <description>&lt;BR /&gt;$YOUR_STRING=1234567&lt;BR /&gt;$STRING_NUM=`echo "$YOUR_STRING\c" | wc -c`&lt;BR /&gt;&lt;BR /&gt;#echo $STRING_NUM&lt;BR /&gt;7</description>
      <pubDate>Wed, 01 May 2002 13:50:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714841#M61516</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2002-05-01T13:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714842#M61517</link>
      <description>a=$(echo hello | wc -c)&lt;BR /&gt;((a=a-1))&lt;BR /&gt;echo $a&lt;BR /&gt;5&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dave.</description>
      <pubDate>Wed, 01 May 2002 13:50:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714842#M61517</guid>
      <dc:creator>David Burgess</dc:creator>
      <dc:date>2002-05-01T13:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714843#M61518</link>
      <description>The ${#&lt;PARAMETER&gt;} construct is by far the most efficient because it is evaluated by the shell itself rather than calling a seperate process.&lt;BR /&gt;&lt;BR /&gt;Bear in mind however that it is not valid in the real Bourne shell (/usr/old/bin/sh). You're not using that are you?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PARAMETER&gt;</description>
      <pubDate>Wed, 01 May 2002 13:54:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714843#M61518</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-05-01T13:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714844#M61519</link>
      <description>Shannon,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;$ DAH1="this is a test"&lt;BR /&gt;$ echo $DAH1&lt;BR /&gt;this is a test&lt;BR /&gt;$ echo ${#DAH1}&lt;BR /&gt;14&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;If it works you are really using the posix shell. The bourne shell in 10+ is in /usr/old/bin. The bourne shell still exists for older scripts, and should be "ported" to the posix shell.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Wed, 01 May 2002 14:00:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714844#M61519</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-05-01T14:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714845#M61520</link>
      <description>Hi Shannon,&lt;BR /&gt;&lt;BR /&gt;# var=0123456789&lt;BR /&gt;# echo ${#var}&lt;BR /&gt;10&lt;BR /&gt;&lt;BR /&gt;Magdi</description>
      <pubDate>Wed, 01 May 2002 14:24:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2714845#M61520</guid>
      <dc:creator>Magdi KAMAL</dc:creator>
      <dc:date>2002-05-01T14:24:58Z</dc:date>
    </item>
  </channel>
</rss>

