Because sometimes one pipe just isn't enough
This project is about handling pipes and redirections, just like the shell does.
Pipex is a 42 project that recreates the behavior of shell pipes and redirections in C. It demonstrates deep understanding of process management, file descriptors, pipes, and command execution.
The program mimics the shell command:
< file1 cmd1 | cmd2 > file2This project introduces students to:
- Process creation and management (fork, execve)
- Inter-process communication (pipes)
- File descriptor manipulation
- Command path resolution and execution
- Single pipe functionality:
cmd1 | cmd2 - Input/output redirection:
< input_fileand> output_file - Command path resolution: Finds commands in PATH
- Error handling: Comprehensive error management
- Memory management: Proper allocation and freeing
🎯 FULL BONUS IMPLEMENTED - All extra features completed!
- 🧩 Multiple Pipes: Handle unlimited commands like a boss -
cmd1 | cmd2 | cmd3 | ... | cmdn - 📝 Here Document: Support for
<<delimiter with custom limiters - 📎 Append Mode:
>>redirection that plays nice with existing files - 🛡️ Robust Error Handling: Gracefully handles everything that can go wrong (and trust me, a lot can)
# Pipe party! Multiple commands dancing together
$ ./pipex file1 "cat" "grep gold" "sort" "uniq" "wc -l" result.txt
# Here document magic - like a conversation with your terminal
$ ./pipex here_doc EOF "grep treasure" "sort -r" "head -5" findings.txt
# Append mode - because overwriting is so rude
$ ./pipex log.txt "tail -f" "grep error" "sed 's/error/bug/'" >> all_errors.txtThe project is written in C and requires:
gcccompiler- Make
- Custom Libft library (included)
1. Compiling the project
To compile the mandatory part:
$ makeTo compile the bonus part (recommended - it's cooler):
$ make bonus2. Running the program
Basic usage (mandatory):
$ ./pipex file1 "cmd1" "cmd2" file2Bonus usage (the fun part):
$ ./pipex file1 "cmd1" "cmd2" "cmd3" ... "cmdn" file2Here Document usage (bonus):
$ ./pipex here_doc LIMITER "cmd" "cmd1" filesrc/- Main source files for mandatory partbonus/- Where the magic happens - Bonus implementationinclude/- Header fileslibft/- Custom Libft library.vscode/- VS Code configurationMakefile- Build configuration
Test your pipe skills:
# Basic test - are you alive?
$ ./pipex input.txt "ls -l" "wc -l" output.txt
# Stress test - how many pipes can you handle?
$ ./pipex big_file.txt "cat" "grep x" "sort" "uniq" "wc -l" final.txt
# Error handling - break it if you can!
$ ./pipex non_existent.txt "invalid_cmd" "wc -l" output.txt
When life gives you pipes, make a pipeline! 🎯
Now with 100% more bonus features! 🎪
"I pipe, therefore I am" - René Descartes (probably)