<?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: char in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916541#M103979</link>
    <description>.</description>
    <pubDate>Mon, 08 Aug 2005 18:15:51 GMT</pubDate>
    <dc:creator>Oliver_39</dc:creator>
    <dc:date>2005-08-08T18:15:51Z</dc:date>
    <item>
      <title>char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916533#M103971</link>
      <description>I need to an input in a script not to accept more or less than eight characters.&lt;BR /&gt;I want it to accept only eight alphanumeric characters.&lt;BR /&gt;&lt;BR /&gt;10 points for best answer!&lt;BR /&gt;</description>
      <pubDate>Sat, 06 Aug 2005 22:14:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916533#M103971</guid>
      <dc:creator>Oliver_39</dc:creator>
      <dc:date>2005-08-06T22:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916534#M103972</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;there are probably many ways of achieving that; you could try something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;REST=""&lt;BR /&gt;RES=""&lt;BR /&gt;&lt;BR /&gt;message()&lt;BR /&gt;{&lt;BR /&gt;        echo "input 8 alnum chars: \c"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;message&lt;BR /&gt;&lt;BR /&gt;while [ "$RES" != "OK" ]&lt;BR /&gt;do&lt;BR /&gt;        read INPUT&lt;BR /&gt;        REST=$(echo "$INPUT" |tr -d "[[:alnum:]]")&lt;BR /&gt;        if [ "$REST" != "" ]&lt;BR /&gt;        then&lt;BR /&gt;                message&lt;BR /&gt;        else&lt;BR /&gt;                # continue with count check...&lt;BR /&gt;                if [ "${#INPUT}" != 8 ]&lt;BR /&gt;                then&lt;BR /&gt;                        message&lt;BR /&gt;                else&lt;BR /&gt;                        RES=OK&lt;BR /&gt;                fi&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;echo "$INPUT" ok, continue with script&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Sun, 07 Aug 2005 06:36:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916534#M103972</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-08-07T06:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916535#M103973</link>
      <description>Hi,&lt;BR /&gt;echo the string into awk as follow:&lt;BR /&gt;&lt;BR /&gt;echo $AAA | awk '{ A=length($0) } END { if (A == 8) { exit(1) }}'&lt;BR /&gt;&lt;BR /&gt;awk returns 1 if 8 char else return 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 07 Aug 2005 12:57:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916535#M103973</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2005-08-07T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916536#M103974</link>
      <description>I would leverage grep -E -q to return a zero if all is well otherwise non-zero and match on an anchored string:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset X=""&lt;BR /&gt;while [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  do&lt;BR /&gt;    echo "Enter value: \c"&lt;BR /&gt;    read X&lt;BR /&gt;    echo "${X}" | grep -E -q -e "^[[:alnum:]]{8}$"&lt;BR /&gt;    STAT=${?}&lt;BR /&gt;    if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;      then&lt;BR /&gt;        echo "\aInvalid; re-enter.\n"&lt;BR /&gt;      fi&lt;BR /&gt;  done&lt;BR /&gt;echo "X = \"${X}\""&lt;BR /&gt;&lt;BR /&gt;This must return exactly 8 alphanumeric characters.&lt;BR /&gt;</description>
      <pubDate>Sun, 07 Aug 2005 13:50:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916536#M103974</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-08-07T13:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916537#M103975</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;both answers accept alpha?&lt;BR /&gt;I want it to accept only aphanumeric characters?&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Sun, 07 Aug 2005 14:20:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916537#M103975</guid>
      <dc:creator>Oliver_39</dc:creator>
      <dc:date>2005-08-07T14:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916538#M103976</link>
      <description>&lt;BR /&gt;Please explain what you mean with alpha.&lt;BR /&gt;Best I know it is a sub-set of alpha-numeric.&lt;BR /&gt;So 8 alpha = 8 alpha-numeric.&lt;BR /&gt;examples:&lt;BR /&gt;abcdefgh &lt;BR /&gt;12345678&lt;BR /&gt;A1B2C3D3&lt;BR /&gt;counter examples:&lt;BR /&gt;123 5678&lt;BR /&gt;ab%def?h&lt;BR /&gt;&lt;BR /&gt;If need be, give examples of acceptable and not acceptable input.&lt;BR /&gt;&lt;BR /&gt;Here is an other starting point for a solution:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/csh&lt;BR /&gt;#&lt;BR /&gt;set test&lt;BR /&gt;while (`echo $test | tr '[:alnum:]' '[x*0]'` != 'xxxxxxxx')&lt;BR /&gt;set  test=$&amp;lt;&lt;BR /&gt;echo "--$test--"&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;any and all alphanumerics in $test are replaced by an 'x' (x*0 = unlimited x's :-)&lt;BR /&gt;If the result is 8 x's, the input must have been valid.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;hein.&lt;BR /&gt;</description>
      <pubDate>Sun, 07 Aug 2005 14:42:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916538#M103976</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-08-07T14:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916539#M103977</link>
      <description>Try this script.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;echo "Enter input word";&lt;BR /&gt;read word;&lt;BR /&gt;&lt;BR /&gt;LEN=$(echo $word | awk '{ print length($1) }')&lt;BR /&gt;&lt;BR /&gt;if [[ ${LEN} -ge 8 ]]&lt;BR /&gt;then&lt;BR /&gt;  ALPLEN=$(echo $word | tr -d '[[:alnum:]]'| awk '{ print length($1) }')&lt;BR /&gt;  if [[ ${LEN} -eq 8 ]]&lt;BR /&gt;  then&lt;BR /&gt;&lt;BR /&gt;    echo "Entered word $WORD is having 8 alphanumeric characters"&lt;BR /&gt;&lt;BR /&gt;  else&lt;BR /&gt;      echo "Entered word $WORD is not having 8 alphanumeric characters"&lt;BR /&gt;&lt;BR /&gt;  fi&lt;BR /&gt;else&lt;BR /&gt;  echo "Entered word $WORD is having less than 8 characters"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Mon, 08 Aug 2005 00:29:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916539#M103977</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-08-08T00:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916540#M103978</link>
      <description>Well you can use 'typeset -L' to specify the length of variable contents that it can take. &lt;BR /&gt;&lt;BR /&gt;$ cat script&lt;BR /&gt;typeset -L8 myVar&lt;BR /&gt;echo "Enter value for myVar: \c"&lt;BR /&gt;read myVar&lt;BR /&gt;echo "myVar is " $myVar&lt;BR /&gt;&lt;BR /&gt;$ ./script  &lt;BR /&gt;Enter value for myVar: jlfjldjf98df9dskljfsdu&lt;BR /&gt;myVar is  jlfjldjf&lt;BR /&gt;&lt;BR /&gt;You can add the check for alphanumeric content over top of it.</description>
      <pubDate>Mon, 08 Aug 2005 01:09:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916540#M103978</guid>
      <dc:creator>Amit Agarwal_1</dc:creator>
      <dc:date>2005-08-08T01:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: char</title>
      <link>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916541#M103979</link>
      <description>.</description>
      <pubDate>Mon, 08 Aug 2005 18:15:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/char/m-p/4916541#M103979</guid>
      <dc:creator>Oliver_39</dc:creator>
      <dc:date>2005-08-08T18:15:51Z</dc:date>
    </item>
  </channel>
</rss>

