https://drive.google.com/file/d/19s1QCUotJxLb93VCmH1lbYTs7qu0oQQo/view?usp=sharing
This repository contains a C program named minibash which acts as a simple shell that goes into an infinite loop waiting for user's commands. Once a command is entered, the program assembles and executes each command using fork(), exec(), and other system calls as required.
- Execute Commands: Execute commands entered by the user using
fork()andexec(). - Special Characters: Handle special characters like
#,~,+,|,<,>,>>,;,&&, and||. - Process Management: Run processes in the background and bring them to the foreground.
- File Operations: Perform file operations like word count, file concatenation, and redirection.
minibash$dter: Kills the current minibash terminal.#: Counts the number of words present in a specified.txtfile.- Example:
minibash$ # sample.txtoutputs the number of words insample.txt.
- Example:
~: Concatenates specified.txtfiles.- Example:
minibash$ sample1.txt ~ sample2.txt ~ temp1.txt ~ temp2.txtconcatenates the files in order.
- Example:
+: Runs a process in the background.- Example:
minibash$ ex10 30 20 a +runsex10 30 20 ain the background. minibash$ forebrings the last background process to the foreground.
- Example:
|: Piping operations (up to 4 pipes supported).- Example:
minibash$ ls -l -t -a | grep *.txt | wc | wc -w.
- Example:
<, >, >>: Input and output redirection.- Example:
minibash$ grep to < sample.txtfor input redirection. - Example:
minibash$ ls -1 > dirlist.txtfor output redirection. - Example:
minibash$ ls -1 >> dirlist.txtfor output redirection with append.
- Example:
;: Sequential execution of commands (up to 4 commands).- Example:
minibash$ date ; pwd ; ls -l -t -a.
- Example:
&&, ||: Conditional execution (up to 4 operators supported, combination of && and || possible).- Example:
minibash$ ex1 && ex2 && ex3 && ex4. - Example:
minibash$ c1 && c2 || c3 && c4.
- Example:
- Kill minibash terminal:
$ minibash$dter - Word count in a file:
$ minibash$ # sample.txt - Concatenate files:
$ minibash$ sample1.txt ~ sample2.txt - Run a process in the background:
$ minibash$ ex10 30 20 a + - Piping commands:
$ minibash$ ls -l -t -a | grep *.txt | wc | wc -w - Input redirection:
$ minibash$ grep to < sample.txt - Output redirection:
$ minibash$ ls -1 > dirlist.txt - Sequential execution:
$ minibash$ date ; pwd ; ls -l -t -a - Conditional execution:
$ minibash$ ex1 && ex2 && ex3 && ex4
- Avoid creating a "fork bomb". Use
$killall -u usernameperiodically.
Meet Patel