Answer to Question #306602 in UNIX/Linux Programming for Mickey

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

1
Expert's answer
2022-03-08T07:11:21-0500
#!/bin/bash

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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS