Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
/ pipex Public archive

pipex is a 42 school project aimed to better understand shell redirection and pipes, by handling them in C.

Notifications You must be signed in to change notification settings

mcombeau/pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pipex

Pipex 42 project badge

pipex is a 42 school project aimed to better understand shell redirection and pipes, by handling them in C.

This project has been archived in the state it was in at the time of evaluation.

This pipex program takes an input file, performs a command on it, pipes the result to another command which then writes its result to an output file. The result is virtually identical to this kind of shell command:

$ < input_file command1 | command2 > output file

🇺🇸 Read my articles in English about the concepts tackled in this project:

🇫🇷 Lire mes articles en français sur les concepts abordés dans ce projet :


Status

Finished 01/05/2022. Grade: 118% (here_doc bonus failed: prints an extra prompt line after LIMITER is given as input.)

Usage

To compile, use make, make all or make bonus.

Regular pipex execution

Pipex can handle 2 or more commands. To execute:

$ ./pipex input_file command1 command2 ... commandn output_file

The output will be written to the specified output file. If the output file exists, it will be overwritten. This replicates the shell command:

$ < input_file command1 | command2 | ... | commandn > output_file

Each command can be given arguments and options if surrounded by quotation marks. For example:

$ ./pipex example.txt "cat" "grep x" "sed s/l/.../g" outfile.txt

Pipex heredoc execution

You can also run pipex with a heredoc, like this:

$ ./pipex here_doc LIMITER command1 command2 ... commandn output_file

You will then be asked to input text which will be used as input for the commands. In this case, the specified output file will not be overwritten but appended, which replicates the behavior of the shell command:

$ << LIMITER command1 | command2 | ... | commandn >> output_file

Made by mcombeau: [email protected] | LinkedIn: mcombeau | Website: codequoi.com