Directory management operations menu

Write a script to make following file and directory management operations menu based:

  • Display current directory
  • List directory
  • Make directory
  • Change directory
  • Copy a file
  • Rename a file
  • Delete a file
  • Edit

 

flag=1

while [ $flag -eq 1 ]

do

echo 1.Display Current Directory

echo 2.List Directory

echo 3.Make Directory

echo 4.Change Directory

echo 5.Copy a File

echo 6.Rename a file

echo 7.Delete a file

echo 8.Edit

echo 9.Exit

echo Enter your choice::

read n

case $n in

1)

pwd

;;

2)

echo

ls

echo

echo

;;

3)

echo “Enter the new Directory name”

read dir

mkdir $dir

;;

4)

while true;do

echo -e “Enter the directory name ::\c”

read path1

[[ -d $path1 ]] && break

echo Invalid name

done

cd $path1

;;

5)

rm file1

echo “Enter the file namE which you want to create copy”

read file

cp file1 $file

cat file1

;;

6)

echo

ls

echo

echo “Enter the file name which you rename”

read file

echo “Enter the new name”

read nfile

mv $file $nfile

echo

ls

echo

;;

7)

echo

ls

echo

echo “Enter the file name you want to delete”

read file

if [ -f $file ]

then

echo Do you want to confirm delete[y/n]

read y

if [ y=’y’ ]

then

rm $file

fi

fi

;;

8)

echo “Enter the file name where you want to edit”

read file

cat file

echo

echo “Edit the file….”

cat >> file

;;

9)

flag=0

;;

*)

echo Invalid choice

;;

esac

done

 

 

Share

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.