Question #306602

Write a shell program where user will take name of person. The program will return corresponding age of person on console .Shell will read value from a file called as info.txt where user information is stored in the format mentioned below

Name:Age

Expert's answer

#!/bin/bash

name=$1
if [[ -z $name ]]; then
   echo "Enter name:"
   read name
fi
age=`grep ^${name}: info.txt | cut -f2 -d:`
echo $age
LATEST TUTORIALS
APPROVED BY CLIENTS