Skip to content

Developed a Unix-like shell in C with support for I/O redirection and multiple piping operations. Compiled using a Makefile, the shell emulates standard UNIX shell behavior. README demostrates various use cases of provided shell functionalities.

Notifications You must be signed in to change notification settings

dcruzeneil/unix-shell-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Unix Shell Implementation

This project features a C program that implements a Unix-like shell, supporting I/O redirection and piping.

Compiling the Code

To compile the program, use the provided Makefile:

make

Using the Shell

To start the shell (assuming you are in the same directory):

./mysh

This will bring you to a prompt that looks like this:

$

You can now use this shell similarly to the default UNIX shell. Below are some demonstrations of the I/O redirection and piping support. These operations can be combined, as shown in the piping examples.

Input Redirection

To read input from a file called input.txt:

$ cat < input.txt

Note: This is not a typical use of the cat command but is done for demonstration purposes.

Output Redirection

To write the output of ls -al to a file called output.txt and to overwrite everything previously written in output.txt:

$ ls -al > output.txt

However, to append to output.txt:

$ ls >> output.txt
Piping Support

This shell supports multiple piping, allowing the output of one program to be passed as input to another. This is useful in various scenarios.

For example, to read a file's content, count the number of lines, and store the count in another file:

$ cat output.txt | wc -l > line_count

To read a file's contents, find a specific keyword (say mysh), count the number of lines where the keyword appears, and store the output in a new file:

$ cat output.txt | grep -i mysh | wc -l > grepped_line_count

To test multiple piping support, you can chain several cat commands:

$ cat output.txt | grep -i mysh | wc -l | cat | cat | cat | cat > grepped_line_count

Exiting the Shell

To exit the shell, type the exit command or press CTRL + D.

About

Developed a Unix-like shell in C with support for I/O redirection and multiple piping operations. Compiled using a Makefile, the shell emulates standard UNIX shell behavior. README demostrates various use cases of provided shell functionalities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors