Kolam Ayer MakersLinux Foundations

Standard Input

Core Idea

Standard input is where commands read text when no filename is supplied.

Three common sources feed stdin:

Practice Alone

Type input into read, then pipe text into commands that read stdin.

printf 'Type your name: '
read -r name
printf 'Hello, %s\n' "$name"

Pipe text into a command:

printf 'one\ntwo\nthree\n' | wc -l

Redirect a file into stdin:

wc -l < /etc/services

Watch Out

Done When

You can explain why pipes and read both depend on stdin.

Docs Pointers