Skip to content

Instantly share code, notes, and snippets.

@brennen
Created May 31, 2019 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brennen/9bbb94976a4e8fd1d1b126c73e4929aa to your computer and use it in GitHub Desktop.
Save brennen/9bbb94976a4e8fd1d1b126c73e4929aa to your computer and use it in GitHub Desktop.
read stdin in a shell function
brennen@inertia 14:31:49 ~/fragments (master m2/u4) ▣ cat func-stdin.sh
#!/bin/sh
myread () {
while read foo; do
echo "$foo";
done
}
cat /etc/motd | myread
brennen@inertia 14:31:52 ~/fragments (master m2/u4) ▣ ./func-stdin.sh
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment