obda.net

Redirect STDIN in a Shell Script

Add a comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

If you have a shell script, and want to redirect all input it receives via STDIN to another script or program, use <&0:

#!/bin/zsh
/path/to/another/script.pl --script-args <&0