I would like a Bash script that can take input from a file or stdin, much like grep, for example
grep
$ cat
$ cat ts.sh read b < "${1-/dev/stdin}" echo $b $ ./ts.sh <<< 'hello world' hello world
No problem for me. I'm using bash 4.2.42 on Mac OS X.