D: How do I pipe (|) through three programs using std.process?

BoQsc vaidas.boqsc at gmail.com
Sat Nov 11 17:29:14 UTC 2023


https://dlang.org/library/std/process.html

How do I pipe (|) through three programs using std.process?

I'm getting confused again about what functions should I use to 
efficiently mimick piping like it is done in some shells (Linux 
bash, Windows cmd):

Here I will provide something to test against on Windows 
Operating System.


**Shell example on Windows:**
```
echo This is a sample text | find "sample" | find "text"
```
**Output if piping works:**
```
This is a sample text
```
![](https://i.imgur.com/8MOp4X4.png)

**Output if it does not:**
```

```
![](https://i.imgur.com/yK71GbZ.png)


**Explanation:**
`echo` is used to print output to stdout.
The output is redirected as **input** to a `find` command.
The `find "textToFind"` command finds matching text in the stdin 
input.

Windows `find` command:
* If text matches it **returns the whole given input**.
* If the text does not match, **it returns nothing**.


More information about the Digitalmars-d-learn mailing list