This project is an introduction to topics such as: parent and child processes, pipes, redirections; a prerequisite to a later project (minishell).
https://github.com/vfurmane/pipex-tester
https://www.codequoi.com/en/creating-and-killing-child-processes-in-c/
https://www.codequoi.com/en/pipe-an-inter-process-communication-method/
https://www.codequoi.com/en/handling-a-file-by-its-descriptor-in-c/
- Clone the repository
git clone https://github.com/rsoo23/pipex.git pipex
- Make the executable
make
- Input the arguments in the format: Single Pipe: The program handles 2 commands, getting the input from the infile and writing the output to the outfile.
./pipex infile cmd1 cmd2 outfile
This replicates:
./pipex < infile cmd1 | cmd2 > outfile
Example:
./pipex infile.txt "grep make" "wc -l" outfile.txt
Multiple Pipes: The program handles > 2 commands using multiple pipes.
./pipex infile cmd1 cmd2 ... cmdn outfile
This replicates:
./pipex < infile cmd1 | cmd2 | .. | cmdn > outfile
Example:
./pipex infile.txt "grep make" "wc -l" "cat -e" outfile.txt
Here_doc: The program receives input from the standard input (STDIN) until the limiter is entered and executes the commands, writing the output to the outfile.
./pipex here_doc limiter cmd1 cmd2 outfile
This replicates:
./pipex cmd1 << limiter | cmd2 >> outfile
Example:
./pipex here_doc stop "grep hi" "wc -w" outfile.txt