A Unix shell implementation written in C++ from scratch for learning purposes. Supports pipelines, I/O redirection, job control, and signal handling.
- Linux or macOS
- g++ with C++17 support
- make
git clone https://github.com/ValijonSharifjon/mini-shell.git
cd mini-shell
make./myshellTo exit:
myshell>> exitAny command available on your system works:
myshell>> ls
myshell>> echo hello world
myshell>> cat file.txt| Command | Description |
|---|---|
cd <dir> |
Change directory |
pwd |
Print current directory |
jobs |
List background jobs |
fg %<n> |
Bring job to foreground |
bg %<n> |
Resume job in background |
exit |
Exit the shell |
Chain commands together with |:
myshell>> ls | grep .cpp
myshell>> cat file.txt | sort | uniq
myshell>> ps aux | grep sleepmyshell>> echo hello > output.txt # write stdout to file
myshell>> cat < input.txt # read stdin from file
myshell>> ls 2> errors.txt # write stderr to file
myshell>> ls 2>&1 # redirect stderr to stdout
myshell>> ls | grep txt > result.txt # pipe and redirect togetherRun a command in the background with &:
myshell>> sleep 100 &
[1] 12345
myshell>> # prompt returns immediatelymyshell>> sleep 100 &
[1] 12345
myshell>> sleep 200 &
[2] 12346
myshell>> jobs
[1] Running sleep 100
[2] Running sleep 200
myshell>> fg %1 # bring sleep 100 to foreground
myshell>> bg %1 # resume in background after Ctrl+Z| Shortcut | Action |
|---|---|
Ctrl+C |
Kill foreground process (shell stays alive) |
Ctrl+Z |
Suspend foreground process |
Ctrl+\ |
Ignored |
| Command | Description |
|---|---|
make |
Build the project |
make test |
Run tests |
make format |
Format code |
make clean |
Remove binary |