Subject: | |
From: | |
Reply To: | |
Date: | Wed, 26 Oct 2005 15:13:07 -0600 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Thanks Ken!
This is fantastic! multiple birds with only a few stones. now i
understand how to do the grep, the tests, and how to code a function, too.
This list is great!
Ken Hirsch wrote:
> 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
>
--
----------------------------------------------------------------------
John MacLerran
IT Systems Analyst email: [log in to unmask]
Idaho State University V(208) 282-2954
http://www.isu.edu/~macljohn F(208) 282-3673
----------------------------------------------------------------------
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|