Naar de inhoud
← Alle termen

stdin / stdout / stderr

28-10-2026 door Bernard in Geen categorie

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.

Omleiding

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

Pipes

Een pipe koppelt de stdout van het ene proces aan de stdin van het volgende:

ls | grep ".txt"

/dev/null

/dev/null is een speciaal bestand dat alles weggooit. Uitvoer die je niet wilt zien stuur je erheen:

commando > /dev/null 2>&1

Zie ook

  • pipe — stdout aan stdin koppelen
  • redirect — omleiding uitgelegd
  • shell — de omgeving waar stromen worden beheerd
  • tty — de terminal waaraan stromen standaard gekoppeld zijn
Reactie? Stuur ons een bericht via ons contactformulier.