This is a simple shell implementation in C created as part of an assignment. The shell supports basic commends like cd
, help
, input/output redirection, and some custom commends (add
, mul
, factorial
,strrev
etc.. ) that are executed from user-defined executable files.
N.B : To execute any user defined command you need to keep command.c file in a subdirectory named 'ExecutableFiles' and add the program name at customCommend[] character array of convertCMD() function
-
Custom commends:
add
: Adds two numbers.mul
: Multiplies two numbers.factorial
: Computes the Factorial of a given number.strrev
: Computes the Reverse of a given string.
-
Built-in commends:
cd <directory>
: Change the current working directory.help
: Displays the Bash manual.exit
orclear
: Terminates the shell.ls
: Shows fiels and folders of the directory
-
Input/Output Redirection:
- Redirect input using
<commend> < <sourcefile.txt>
. - Redirect output using
<commend> > <destinationfile.txt>
.
- Redirect input using
-
Clone the Repository or Navigate to the Project Directory.
-
Compile the Program:
- The project includes a
Makefile
to automate the compilation process. You can compile the program using the following commend:make
- The project includes a
-
Run the Shell:
- Once compiled, you can run the shell with the following commend:
./shell
- Once compiled, you can run the shell with the following commend:
-
Use the Custom and Built-in commends:
- You can use any of the custom commends (
add
,mul
,factorial
) or built-in commends (cd
,help
,exit
) from the shell prompt.
- You can use any of the custom commends (
-
To Terminate the Shell:
- Use the
exit
orclear
commend to exit the shell.
- Use the
-
Clean the Program:
- Clean all executable files by using:
make clean
- Clean all executable files by using:
- Custom commend - add:
add 5 7
- Custom commend - mul:
mul 5 7
- Custom commend - factorial:
factorial 5 7
- Custom commend - strrev:
strrev testingString
- Custom commend - input redirection (Assum we have sourcefile.txt):
add < sourcefile.txt
- Custom commend - output redirection :
add 4 5 > detinationfile.txt