A custom command shell that supports both interactive and batch modes. It includes built-in commands such as exit, cd, and alias, as well as support for input/output redirection.
- Interactive Mode: Run the shell interactively, executing commands one at a time.
- Batch Mode: Read and execute commands from a script file in batch mode.
- Built-in Commands:
exit: Terminate the shell.cd: Change the current working directory.alias: Create and manage command aliases.
- I/O Redirection: Redirect input and output for commands.
- Your system should have a C compiler installed (e.g., GCC).
make./newshell
./newshell batchFile.txt- Launch the shell.
- Enter commands interactively.
- Use built-in commands (exit, cd, alias) and I/O redirection.
$ ./newshell
Shell> ls -l
... (output)
Shell> cd /path/to/directory
Shell> exit- Prepare a script file with commands.
- Run the shell with the script file.
./newshell batchFile.txtexitTerminate the shell. If the exit command is on the same line with other commands, the other commands will execute (and finish) before shell is exited.
Shell> exitcdChange the current working directory.
Shell> cd /path/to/directoryaliasDefine shortcuts for commands usingalias alias_name='command'. Use alias with no arguments to display all existing aliases. Remove a single alias withalias -r alias_nameor all defined aliases withalias -c. This custom alias command substitutes a given string for a command, resembling the bash alias but implemented as a built-in command for proper shell execution control.
Shell> alias 5='ls -al'
Shell> 5
... (output of 'ls -al' command)Redirect input and output for commands.
Shell> ls > output.txt
Shell> cat < input.txt