Azazia Software Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

Quick One liners to test a string whether or not it is an Integer, Alphanumeric, or Character

Add comment
Views: 537
Votes: 0
Comments: 0
Posted: 16 Nov, 2009
by: Patridge B.
Updated: 16 Nov, 2009
by: Patridge B.
*note:
Solaris egrep flag = "-e"
Linux egrep flag = "-E"

To test a string whether or not it is numeric:
-------------------------------------------------
# echo <string> |egrep -E '^[0-9]+$'
# echo $?
*note
1 = not numeric
0 = is numeric
-------------------------------------------------



To test a string whether or not it is all lower case Characters:
-------------------------------------------------
# echo <string> |egrep -E '^[a-z]+$'
# echo $?
*note
1 = not successful
0 = is successful
-------------------------------------------------



To test a string whether or not it is all upper case A-Z characters
-------------------------------------------------
# echo <string> |egrep -E '^[A-Z]+$'
# echo $?
*note
1 = not successful
0 = is  successful
-------------------------------------------------



To test a string whether or not it is all upper case and lower case A-Z characters
-------------------------------------------------
# echo <string> |egrep -E '^[A-Za-z]+$'
# echo $?
*note
1 = not successful
0 = is  successful
-------------------------------------------------




To test a string whether or not it is all alphanumeric characters
-------------------------------------------------
# echo <string> |egrep -E '^[0-9A-Za-z]+$'
# echo $?
*note
1 = not successful
0 = is  successful
-------------------------------------------------
Others in this Category
document VI editor Backup (VIB) Utility
document E:Lists directory /var/lib/apt/lists/partial is missing.
document Regular Expression to Escape all Illegal (non alphanumeric) Characters Except a space
document Using Awk to display a directory listing on files with spaces until the end of line
document UNIX Command Line way to convert HEX ascii codes to Text
document Restoring the cursors last position in the VI (VIM) editor
document Postfix/Sendmail Errors: NOQUEUE: reject: RCPT .... Relay access denied DSN: Service unavailable
document Display path, user name, and host name next to the cursor in the .bashrc or .bash_profile
document Little script to make process searching easier
document Create an SFTP account that will restrict the user only to their destination home directory so they cannot change directory (cd) or view any other files outside of that directory.
document Recompile apache2 to support LDAP on Solaris 10
document SVN Solaris 10: ld: fatal: Symbol referencing errors. No output written to .libs/svn
document SVN Solaris 10: ld.so.1: svnversion: fatal: libssl.so.0.9.8: open failed: No such file or directory
document Solaris 10: commit failed: svn: Couldn't perform atomic initialization
document Creating a UNIX sparse file on an Isilon system



RSS