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
thanks in advance
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
thanks in advance
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"
using awk:
awk -F '|' '{ if($1 !~ /^[0-9]*$/) { print $1 " is not numeric in " $0; } if($2 !~/^[a-zA-Z]*$/) { print $2 " is not alphabetic in " $0 } }' filename