A menu driven shell script for Copy a file, Remove a file, Move a file

clear
echo "Menu "
echo "1. Copy a File "
echo "2. Remove a file "
echo "3. Move a file"
echo "4. Quit"
echo "Enter ur Choice \c"
read Choice
case"$Choice"in
1) echo "Enter File name to copy \c"
read f1
echo "Enter FIle name \c "
read f2
if [ -f $f1 ]
then
cp $f1 $f2
else
echo "$f1 does not exist"
fi
;;
2) echo "Enter the File to be removed "
read r1
if [ -f $r1 ]
then
rm -i
$r1 else
echo "$r1 file does not exist "
fi
;;
3)
echo "Enter File name to move \c"
read f1
echo "Enter destination \c "
read f2
if [ -f $f1 ]
then
if [ -d $f2 ]
then
mv $f1 $f2
fi
else
echo "$f1 does not exist"
fi
;;
4)
echo "Exit......."
exit;;
esac
*********************************************************************
Output:
$ s
h filemenu.sh
Menu
1. Copy a file
2. Move a file
3. Remove a file
4. Quit
Enter ur Choice 2
Enter the File to be removed
abc.txt abc.txt file does not exist
**********************************************************************

Leave a Reply