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
#!/bin/bash
name=$1
if [[ -z $name ]]; then
echo "Enter name:"
read name
fi
age=`grep ^${name}: info.txt | cut -f2 -d:`
echo $age
Comments
Leave a comment