HP3000-L Archives

October 2005, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Wed, 26 Oct 2005 17:08:08 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (49 lines)
John MacLerran wrote:

>specifically, the alpha function on mpe works on a string, but the grep
>command expects a file as its input. i'm not sure how to: 1) grep for alpha
>only characters (i'm thinking that something like [A-Z | a-z] is needed, but
>i'm not sure of the exact syntax), and 2)get grep to look at a string and
>evaluate just that string.  can anyone give some pointers?
>  
>

function isalpha {
  echo "$@" | grep -Eiqe '^[A-Z]+$'
}

testword="hello"
if isalpha $testword
then
  echo $testword is all alphabetic
else
  echo $testword is not all alphabetic
fi

storedbool=$(isalpha $testword; echo $?)
if [ $storedbool -eq 0 ]
then
  echo $testword is all alphabetic
else
  echo $testword is not all alphabetic
fi

testword="hello2"
if isalpha $testword
then
  echo $testword is all alphabetic
else
  echo $testword is not all alphabetic
fi

storedbool=$(isalpha $testword; echo $?)
if [ $storedbool -eq 0 ]
then
  echo $testword is all alphabetic
else
  echo $testword is not all alphabetic
fi

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2