You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Write a Script to Read Employee Data and Insert it into the emp.txt File.
#! /bin/bashwhile [ true ]
doread -p "Employee Number: " eno
read -p "Employee Name: " ename
read -p "Employee Salary: " esal
read -p "Employee Address: " eaddr
echo"$eno:$ename:$esal:$eaddr">> emp.txt
echo"Employee Record Inserted Successfully"read -p "Do you want to insert one more record [Yes|No]: " option
case$optionin
[yY]|[Yy][eE][sS])
continue
;;
[nN]|[nN][oO])
break
;;
esacdoneecho"Open emp.txt to see all employees information"
2. Write a Script to Implement the cat Command with -n Option.
#! /bin/bash
fname="$1"# Quote the variable to handle spaces and special charactersif [ !-f"$fname" ];thenecho"Please provide an already existing regular file only"exit 1
fi
count=1
whileread -r line # Use -r to prevent backslashes from being interpreteddoecho"$count$line"let count++
done<"$fname"