UNIX Shell Script Help


Ques 1: Write shell script for the following

It should display menu for following

Display file contents with line number

display the file contents with page break

quit.

Answer:

echo "\n Enter your choice

\n1)show file content with line number

2) show file content with pagebreak\n

3)quit"

read choice

case "$choice" in

1)echo "enter the file name";read fname;cat -b $fname;;

2)echo "enter the file name";read fname;cat $fname | more;;

3)exit

esac

Quest 2:Write a shell script for accepting the following information and storing in file.i) customer nameii) item descriptioniii) quantityiv) ratethe user should get the facility to enter as many record as he wants.

Answer:

ans=y

echo "enter the file name:\c"

read fname

while [ "$ans" = "y" ]

do

echo "Enter\n customer name |item description| quantity| rate:\c" >/dev/tty

read cname itemd quant rate

echo "$cname|$itemd|$quant|rate" >> $fname

echo "record inserted successfully:\c"

echo "do you want to continue:(y/n)"

read c

case "$c" in

y*|Y*) ans=y;;

n*|N*) ans=n;;

*) ans=y ;;

esac

done

#UNIX #ShellScript

Contact Us

Tel: (+91) 0120  4118730  

Time :   10 : 00  AM -  08 : 00 PM IST 

Registered address: G-69, Sector 63, 

 Noida - 201301, India

We Provide Services Across The different countries

USA    Australia   Canada   UK    UAE    Singapore   New Zealand    Malasia   India   Ireland   Germany

CodersArts is a Product by Sofstack Technology Solutions Pvt. Ltd.

  • CodersArts | Linkedin
  • Instagram