read stdin in function in bash script
If the question is How do I pass stdin to a bash function?, then the answer is: Shellscript functions take stdin the ordinary way, as if they were commands or programs. 🙂 input.txt: HELLO WORLD HELLO BOB NO MATCH test.sh: #!/bin/sh myfunction() { grep HELLO } cat input.txt | myfunction Output: hobbes@metalbaby:~/scratch$ ./test.sh HELLO WORLD … Read more