OSA: Directory- create,delete,display PWD and change directory

while(true)
do
echo " MENU
------------------------------------------------------------------------------
1)Make a new directory
2)Delete a directory
3)Display current working directory
4)Change directory"

read choice
case $choice in

1) echo " New directory
==============================================================================
Enter name of directory to be created ->"
read name
if [ -d $name ];
then
echo "directory already exists, please try another name"
else
mkdir $name
echo "directory has been created successfully"
fi
;;

2) ls
echo " Delete directory
==============================================================================
Enter the name of directory to be deleted ->"
read dname
if [ -d $dname ];
then
rmdir $dname
echo "directory has been deleted  "
else
echo "invalid name, please try a valid directory name"
fi
;;

3) echo " Present working directory
-----------------------------------------------------------------------------"
pwd
;;

4) echo " change directory
-----------------------------------------------------------------------------
Enter the new directory path ->"
read path
cd $path
echo "directory has been changed"
;;

5) echo "Program terminated"
exit 0
;;

esac
done

#tnx for using code from http://www.parazhar.blogspot.in


Comments

Popular posts from this blog

NASM: program to find largest number from an array of 32-bit numbers(hard-coded)

Rules for drawing a FLOWCHART