clear
ch=1
while true
do
echo
echo "Directory Operation"
echo "************"
echo "1.Directory Creation"
echo "2.Remove Directory"
echo "3.Copy file to directory"
echo "4.Move file to directory"
echo "5.Change Directory"
echo "6.Exit"
echo "Enter your choice"
read ch
case $ch in
1)
echo "Directory Creation"
echo "***********"
echo
echo "Enter the directory name"
read m
if test -d $m
then
echo "Directory already exists"
else
mkdir $m
ls -x
echo "Directory Created"
fi
;;
2)
echo "Remove directory"
echo "***********"
echo
echo "Enter your directory"
read m
if test -d $m
then
cd $m
ls -x
rm *
cd
cd
rmdir $m
echo "Directory Removed"
else
echo "Directory not found"
fi
;;
3)
echo "Copy a file to directory"
echo "*************"
echo
echo "Enter your file name"
read f
if test -f $f
then
echo "File already exists"
echo "Enter the destination directory name:"
read ds
if test -d $ds
then
echo "Directory already exists"
cp $f $ds
echo "Copied successfully"
else
echo "Directory not exists"
fi
else
echo "File not present"
fi
;;
4)
echo "Move a file to directory"
echo "**************"
echo
echo "Enter the file name"
read f
if test -f $f
then
echo "File already exists"
echo "Enter the destination directory"
read ds
if test -d $ds
then
echo "Directory already exists"
mv $f $ds
echo "Moved successfully"
else
echo "Directory not exists"
fi
else
echo "File not present"
fi
;;
5)
echo "Change Directory"
echo "**********"
echo
echo "Enter your directory name"
read n
if test -d $n
then
cd $n
ls
echo "Enter your file name to be view"
read n
echo "The contents of the file"
echo
cat $n
cd
else
echo "The Directory not exists"
fi
;;
6)
echo "Exit"
exit
;;
esac
done
----------
Output:
*******
Directory Operation
****************
1.Directory Creation
2.Remove Directory
3.Copy file to directory
4.Move file to directory
5.Change directory
6.Exit
Enter your choice
1
Directory Creation
***********
Enter your directory name
varshini
a aaaa alpha1.sh alpha1.sh alpha.sh anbu a.out
asd ball dad dddd deepa depa dhars
do.sh durga ebill.sh employee f3 fdf friends
Directory Created
Enter your choice
2
Remove directory
***********
Enter your directory
anbu
surya
Directory Removed
Enter your choice
3
Copy a file to directory
**************
Enter your file name
fdf
File already exists
Enter your destination directory name:
depa
Directory already exists
Copied successfully
Enter your choice
4
Move a file to directory
**************
Enter the file name
fdf
File already exists
Enter the destination directory
deepa
Directory already exists
Moved Successfully
Enter your choice
5
Change Directory
***********
Enter the directory name
dad
add dsa rs
Enter the file name to be view
dsa
The contents of the file
priya
raji
hello
hai
welcome
Enter your choice
6
Exit
ch=1
while true
do
echo
echo "Directory Operation"
echo "************"
echo "1.Directory Creation"
echo "2.Remove Directory"
echo "3.Copy file to directory"
echo "4.Move file to directory"
echo "5.Change Directory"
echo "6.Exit"
echo "Enter your choice"
read ch
case $ch in
1)
echo "Directory Creation"
echo "***********"
echo
echo "Enter the directory name"
read m
if test -d $m
then
echo "Directory already exists"
else
mkdir $m
ls -x
echo "Directory Created"
fi
;;
2)
echo "Remove directory"
echo "***********"
echo
echo "Enter your directory"
read m
if test -d $m
then
cd $m
ls -x
rm *
cd
cd
rmdir $m
echo "Directory Removed"
else
echo "Directory not found"
fi
;;
3)
echo "Copy a file to directory"
echo "*************"
echo
echo "Enter your file name"
read f
if test -f $f
then
echo "File already exists"
echo "Enter the destination directory name:"
read ds
if test -d $ds
then
echo "Directory already exists"
cp $f $ds
echo "Copied successfully"
else
echo "Directory not exists"
fi
else
echo "File not present"
fi
;;
4)
echo "Move a file to directory"
echo "**************"
echo
echo "Enter the file name"
read f
if test -f $f
then
echo "File already exists"
echo "Enter the destination directory"
read ds
if test -d $ds
then
echo "Directory already exists"
mv $f $ds
echo "Moved successfully"
else
echo "Directory not exists"
fi
else
echo "File not present"
fi
;;
5)
echo "Change Directory"
echo "**********"
echo
echo "Enter your directory name"
read n
if test -d $n
then
cd $n
ls
echo "Enter your file name to be view"
read n
echo "The contents of the file"
echo
cat $n
cd
else
echo "The Directory not exists"
fi
;;
6)
echo "Exit"
exit
;;
esac
done
----------
Output:
*******
Directory Operation
****************
1.Directory Creation
2.Remove Directory
3.Copy file to directory
4.Move file to directory
5.Change directory
6.Exit
Enter your choice
1
Directory Creation
***********
Enter your directory name
varshini
a aaaa alpha1.sh alpha1.sh alpha.sh anbu a.out
asd ball dad dddd deepa depa dhars
do.sh durga ebill.sh employee f3 fdf friends
Directory Created
Enter your choice
2
Remove directory
***********
Enter your directory
anbu
surya
Directory Removed
Enter your choice
3
Copy a file to directory
**************
Enter your file name
fdf
File already exists
Enter your destination directory name:
depa
Directory already exists
Copied successfully
Enter your choice
4
Move a file to directory
**************
Enter the file name
fdf
File already exists
Enter the destination directory
deepa
Directory already exists
Moved Successfully
Enter your choice
5
Change Directory
***********
Enter the directory name
dad
add dsa rs
Enter the file name to be view
dsa
The contents of the file
priya
raji
hello
hai
welcome
Enter your choice
6
Exit
0 comments:
Post a Comment