Elk Linux-proces heeft drie standaard gegevensstromen:
| Stroom | Nummer | Betekenis |
|---|---|---|
| stdin | 0 | Standaardinvoer — wat het proces leest |
| stdout | 1 | Standaarduitvoer — normale uitvoer |
| stderr | 2 | Standaardfout — foutmeldingen |
Standaard zijn stdin, stdout en stderr gekoppeld aan de terminal. Via omleiding kun je ze naar bestanden of andere processen sturen.
commando > uitvoer.txt # stdout naar bestand
commando >> uitvoer.txt # stdout toevoegen aan bestand
commando 2> fouten.txt # stderr naar bestand
commando > alles.txt 2>&1 # stdout én stderr naar hetzelfde bestand
commando < invoer.txt # stdin uit bestand lezen
Een pipe koppelt de stdout van het ene proces aan de stdin van het volgende:
ls | grep ".txt"
/dev/null is een speciaal bestand dat alles weggooit. Uitvoer die je niet wilt zien stuur je erheen:
commando > /dev/null 2>&1