while true
do
echo "1.Display first 10 lines in terminal"
echo "2.Display last 10 lines in terminal"
echo "3.Display first 10 lines in f1.txt"
echo "4.Display first 10 lines in f2.txt"
echo "5.Exit"
echo "Enter your Choice"
read ch

case $ch in
1)
	echo -p "Enter File Name :"
	read fname
	if [ -e '$fname' ]
	then
		echo "First 10 lines of $fname: "
		head -n 10 $fname
	else
		echo "File $fname is not found!"
	fi
;;

2)
	echo -p "Enter File Name :"
	read fname
	if [ -e '$fname' ]
	then
		echo "last 10 lines of $fname: "
		tail -n 10 $fname
	else
		echo "File $fname is not found!"
	fi
;;		 

3)
	echo "Enter File Name to take input:"
	read fname
	echo "Enter File Name in Which output is display:"
	read f1
	echo "Check Output in $f1: "
	head -n 10 $fname > $f1
;;
4)
	echo "Enter File Name to take input:"
	read fname
	echo "Enter File Name in Which output is display:"
	read f1
	echo "Check Output in $f1: "
	tail -n 10 $fname > $f2
;;
5)
        echo "Exiting... Goodbye!"
        exit 0
;;
*)
         echo "Invalid choice! Please select between 1-4."
;;
esac
echo "" 
done

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *