Problem: write a simple shell – myshell – that has the following properties: Des
ID: 3884230 • Letter: P
Question
Problem: write a simple shell – myshell – that has the following properties:
Design a simple command line shell that satisfies the below criteria and implement it on a Linux platform.
The shell must support the following internal commands:
- cd <directory> - change the current default directory to <directory>. If the directory argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported. This command should also change the PWD environment variable.
- clr – clear the screen
- dir <directory> - list the contents of directory <directory>
- echo <comment> - display <comment> on the display followed by a new line (multiple spaces/tabs may be reduced to a single space)
- quit - quit the shell
Side notes:
All other command line input is interpreted as program invocation which should be done by the shell forking and executing the programs as its own child processes.
The shell must support background execution of programs. An ampersand (&) at the end of the command line indicates that the shell should return to the command line prompt immediately after launching that program.
The command line prompt must contain the pathname of the current directory.
Explanation / Answer
# Hello World Program in Bash Shell
cd /home/cg #changing directory
echo "Showing the contents of cg"
dir /home/cg/ #showing the contents of directory cg
#clear #clears the terminal
exit #is quiting from bash scripting
#save this file as .sh
output:-
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.