Code:
echo enter
echo 1 to see the contents of /etc/passwd
echo 2 to see list of users
echo 3 to see present working directory
echo 4 exit
echo enter your choice
read n
case $n in
1) ls /etc ;;
2) ls /home;;
3) pwd;;
4) exit;;
*) echo enter the choice as 1,2,3or4;;
esac
Output:
[ty2011330@localhost ~]$ sh file13.sh
enter
1 to see the contents of /etc/passwd
2 to see list of users
3 to see present working directory
4 exit
enter your choice
2
administrator pritam ty11305 ty11313 ty11321 ty11329 ty11337 ty11345
amita pritam1 ty11306 ty11314 ty11322 ty11330 ty11338 ty11346
dipti shital ty11307 ty11315 ty11323 ty11331 ty11339 ty11347
exam5154 shital1 ty11308 ty11316 ty11324 ty11332 ty11340 ty11348
enter your choice
1
a2ps.cfg inittab quotatab
a2ps-site.cfg inputrc racoon
acpi iproute2 raddb
enter your choice
3
/home/tybsc
enter your choice
4
2.
ans=Y
while [ $ans = "Y" ]
do
echo " MENU"
echo "1 . Query on product"
echo "2 . Query on customer"
echo "0 . Exit"
echo "enter ur choice : "
read ch
case "$ch" in
1) echo "Enter product number :"
read pno
grep $pno masterdata
echo "Query on other product : "
read ans
if(test $ans = "Y")
then
continue
fi;;
2) echo "Enter customer number :"
read cno
grep $cno transdata;;
0) exit;;
*) echo "Invalid choice. Try again..."
esac
done
No comments:
Post a Comment