shell24
is a custom shell program written in C that goes into an infinite loop waiting for user commands. It assembles and executes each command using fork()
, exec()
, and other system calls as required.
- Infinite Loop: The shell waits for user commands indefinitely.
- Command Execution: Executes user commands using system calls.
- Special Characters Handling:
- Text File Concatenation (#): Concatenate up to 5 text files.
- Piping (|): Supports up to 6 piping operations.
- Redirection (>, <, >>): Supports input/output redirection.
- Conditional Execution (&&, ||): Supports up to 5 conditional execution operators.
- Background Processing (&): Execute commands in the background and bring them to the foreground.
- Sequential Execution (;): Execute up to 5 commands sequentially.
The program/command newt
(shell24$newt
) must create a new copy of shell24
. There is no upper limit on the number of new shell24
terminal sessions that can be opened.
The argc
(includes the name of the executable/command) of any command/program should be >=1
and <=5
.
shell24$ date
(argc = 1)shell24$ ls -1 -l -t ~/chapter5/dir1
(argc = 5)shell24$ cat input1.txt input2.txt
(argc = 3)
The argc
of individual commands or programs that are used along with the special characters listed below should be >=1
and <=5
.
shell24$ ls -l -t | wc
- The first command has
argc = 3
and the second command hasargc = 1
.
- The first command has
- # Text File Concatenation:
- Example:
shell24$ check.txt # new.txt # new1.txt # sample.txt
- Files are concatenated in the listed order, and the final result is displayed on stdout.
- Example:
- | Piping:
- Example:
shell24$ ls | grep *.c | wc | wc -w
- Supports up to 6 piping operations.
- Example:
- >, <, >> Redirection:
- Example:
shell24$ cat new.txt >> sample.txt
- Example:
- && Conditional Execution:
- Example:
shell24$ ex1 && ex2 && ex3 && ex4
- Example:
shell24$ c1 && c2 || c3 && c4
- Example:
- || Conditional Execution:
- Similar usage as
&&
.
- Similar usage as
- & Background Processing:
- Example:
shell24$ ex1 &
(runsex1
in the background) - Example:
shell24$ fg
(brings the last background process to the foreground)
- Example:
- ; Sequential Execution:
- Example:
shell24$ ls -l -t ; date ; ex1 ;
- Supports up to 5 sequential commands.
- Example:
- Clone the repository:
git clone https://github.com/yourusername/shell24.git
- Navigate to the project directory:
cd shell24
- Compile the program:
gcc -o shell24 shell24.c
Run the shell:
./shell24