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:
John MacLerran <[log in to unmask]>
Reply To:
John MacLerran <[log in to unmask]>
Date:
Wed, 26 Oct 2005 15:13:07 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (70 lines)
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 *

ATOM RSS1 RSS2