Re: Editing in VI

From: Sunder Iyengar (Sunder.Iyengar@VERITAS.COM)
Date: Sun Sep 22 2002 - 19:37:56 EDT


In a Korn shell script, you can do this in the following way.

A shell snippet (example only, modify to suit your requirements),

echo "`hostname`: Enter the email address where you wish to have the output
sent"
read emailaddress
if [[ $emailaddress = +([A-Za-z0-9_-])@+([A-Za-z0-9]).+([a-z])*(.+([a-z]))
]]
  then
    echo "Email address is acceptable"
  else
    echo "Email address not in acceptable format"
fi

The key to the above is in understanding the pattern matching operators in
the Korn shell.

+([A-Za-z0-9_-]) -> one or more upper case alphabet/lower case
alphabet/digits/hyphen/underscore
@ -> the @ symbol
+([A-Za-z0-9]) -> one or more upper case alphabet/lower case alphabet/digits
. -> period
+([a-z]) -> one or more lower case alphabets
*(.+([a-z])) -> zero or more strings where each string consists of a period
followed by one or more lower case alphabets

The above will pass,

dsdas@dsd.dsd
tGt09-f_T@dsjUYY038hT.com
sample@myname.ibm.com

but not,
hgdsgdasf.com
%^#^#8stTh@ibm.com
gdgd67a@myname.ibm.com.
dgsyws@dfhjfRRt.Ibm.COM

Sunder.

-----Original Message-----
From: Dana Jaeger [mailto:jaeger@HARTHOSP.ORG]
Sent: Saturday, 21 September 2002 01:10
To: aix-l@Princeton.EDU
Subject: Editing in VI

Hi,

I have a need to edit an entry via a kron shell script.
Input would be - nnnnnnnn@domain.name

a) nnnnnnnn can be letters and/or numbers, special characters and be any
                   length, uppercase or lower case .
b) domain.name could be any length before and after the dot.
                 example valied entries are A) harthosp.org
                                             B) ibm.com
                                             C) myname.ibm.com
c) @ must be present

This will be entered as a response to a question from an korn shell script
      echo "`hostname`: Enter the email address where you wish to have the
output sent"
      read emailaddress

What would the syntax be to edit for for this?

Can anyone help? Thanks in advance

Dana Jaeger
Hartford Hospital
jaeger@harthosp.org



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:13 EDT