Implement a simplified shell that can execute commands like a Unix shell and print the output to the screen.
- simple commands
- multiple simple commands on one line, separated by semicolons
ls;cal 1 2022 - support excess white space or semicolons between commands
ls ;;;; ;;; ; cal 1 2022 - support redirection
ls > file.txt - support advanced redirection that inserts a command's output at the start of an existing file
ls >+ file.txt - support batch files, where multiple lines of commands can be read from a file
- Run this command
git clone https://github.com/HarrisonD123/Implemented-Unix-Shell.git - In the the project directory, run this command in the terminal:
make myshell - To run the program, enter in the terminal:
./myshell - Once the program is running, type any shell command to see the output
- To redirect output to a file type
<command> > <filename>. Make sure the file name does not already exist in the directory - To use advanced redirection, type
<command> >+ <filename> - There are batch files in the p4shell/batch-files directory. To run the shell with a batch file, type
./myshellfollowed by the batchfile directory:./myshell batch-files/1KCommand - Use
exitto exit the program
Only myshell.c is part of my project. Everything else was preprepared. All code is in C.