The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-07-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by trichyselva View Post
i have a input file like this

001|rahim|bajaj|20090102

while reading the file i need to check whether the first column is a number
second column is a name

is there any methodology to check for the same

Code:
while IFS='|' read a b c d
do
  case $a in
    *[![:digit:]]*) echo First column is not a number ;;
    *) echo First column is a number ;;
  esac

  case $b in
   *[![:alpha:]]*) echo Second column is not a name ;;
   *) echo Second column is a name ;;
  esac
done < "$FILE"