Documente Academic
Documente Profesional
Documente Cultură
/bin/bash
# grepping given mcode in the medslist file and redirecting to file /tmp/result
grep $mcode medslist>/tmp/result
# traversing through /tmp/result file and print required category and medcode
while read line
do
category=$(echo $line|cut -c1-4)
medcode=$(echo $line|cut -c5-12)
genname=$(echo $line|cut -c13-25)
dose=$(echo $line|cut -c26-39)
inventory=$(echo $line|cut -c40-46)
echo "$category $medcode"
done</tmp/result
# below condition will be true if medication code is wrong
if [ ! -s /tmp/result ]
then
echo "No such medication code"
fi
done
NOTE: 'ZZZ' is the string you need to pass to quit out from the loop