In: Computer Science
DOS Command * | Linux Command |
CHDIR [target directory] | cd [target directory] |
CLS | clear |
COPY [source file] [destination file] | cp [source file] [destination file] |
CREATEDIR [directory name] | mkdir [directory name] |
CREATEFILE [file name] | touch [file name] |
DELETE [file name] | rm [file name] |
DIR [file name | directory name | wildcard] | ls [file name | directory name | wildcard] |
MOVE [source] [destination] | mv [source] [destination] |
PRINT [message to print] | echo [message to print] |
QUIT | N/A |
RENAME [old name] [new name] | mv [old name] [new name] |
TYPE [file name] | cat [file name] |
* Assume DOS commands are case-insensitive (i.e., DIR is the same as dir). |
#!/bin/bash
quit="quit"
echo -n "Linux> "
read comm
command1=`echo $comm | tr '[:upper:]' '[:lower:]'`
while [ "$command1" != "$quit" ]
do
echo "Linux> "
read comm
arg1=$1
arg2=$2
command1=`echo $comm | tr '[:upper:]' '[:lower:]'`
case $command1 in
chdir)
echo "chdir"
if [ $arg1 -eq "" ]
then
echo "Please provide direcory name in argument"
else
cd $arg1
fi
;;
cls)
echo "cls"
clear
;;
copy)
echo "Copy"
if [ $arg1 -eq "" ] && [ $arg2 -eq "" ]
then
echo "Please provide arg1 and arg2 for source and
destination filename"
else
cp $arg1 $arg2
fi
;;
createdir)
echo "Create dir"
if [ $arg1 -eq "" ]
then
echo "Please provide direcory name in argument"
else
mkdir $arg1
fi
;;
createfile)
echo "Create file"
if [ $arg1 -eq "" ]
then
echo "Please provide file name in argument"
else
touch $arg1
fi
;;
delete)
echo "Delete"
if [ $arg1 -eq "" ]
then
echo "Please provide file/directory name in argument
to remove."
else
rm -rf $arg1
fi
;;
dir)
echo "Dir"
;;
move)
echo "Move"
;;
print)
echo "Print"
if [ $arg1 -eq "" ]
then
echo "Please provide argument to display
message."
else
echo $arg1
fi
;;
type)
echo "Type"
if [ $arg1 -eq "" ]
then
echo "Please provide file name in argument to display
content."
else
cat $arg1
fi
;;
quit|QUIT)
exit
;;
*)
echo -n "Command Not Found!"
;;
esac
done
if you have any doubt then please ask me without any hesitation
in the comment section below , if you like my answer then please
thumbs up for the answer , before giving thumbs down please discuss
the question it may possible that we may understand the question
different way and we can edit and change the answers if you argue,
thanks :)