Access File Using Switch CASE Bash shell programming using ls rm command in Linux and UNIX

Linux and UNIX command ls refers to list out the files. rm command is used to remove the files, using these command in bash shell programming we are accessing file just like list out and remove the file. CS1252 Operating Systems lap
Source code bash shell Programming Algorithm
echo "Menu"
echo "1.Enter 1 to display the long list of file"
echo "2.Enter 2 to display the long listing file including hidden file"
echo "3.Enter 3 to delete file"
read choice
case $choice in
1)ls;;
2)ls -all;;
3)echo "Enter file to be removed"
read a
echo "File deleted"
rm $a;;
*)echo "Invalid choice"
esac
OUTPUT ACCESS FILE USING SWITCH CASE CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ sh file.sh
Menu
1.Enter 1 to display the long list of file
2.Enter 2 to display the long listing file including hidden file
3.Enter 3 to delete file
3
Enter file to be removed
multable.sh
File deleted

[redhat35@localhost Rhel5]$ sh file.sh
Menu
1.Enter 1 to display the long list of file
2.Enter 2 to display the long listing file including hidden file
3.Enter 3 to delete file
1
palindrome.sh fcfs.sh mtable.sh pattern.sh rr2.c
amstrong.sh fib.sh mubeen pen rr.c
arithmetic.sh file.sh multiplication.sh polindrome.sh semaphore.c
books fruit neela factorial.sh girls pattern1.sh round states
fact.sh greatest.sh pattern2.sh round.c vegitables
fcfs.c linux pattern2.shwq roundrobin.

LIST COMMAND simple bash shell program
echo “ TO DISPLAY LIST OF FILE ”
echo “ 1) ls ”
echo “ 2) ls-al ”
read choice
case $choice in
1)la;;
2)la-al;;
*)echo “ invalid ”;;
esac
OUPUT list command ls unix bash scripting CS1252 Operating Systems lap

[redhat35@localhost Rhel5]$ sh list.sh
TO DISPLAY LIST OF FILE
1) ls
2) ls-al
1
list.sh palin.sh fib.sh fact.sh rr.c
greatest.sh fcfs.c sjf.mul.sh armstr.ch

Post a Comment

0 Comments