How to check if pipe is empty

view full story

http://unix.stackexchange.com – I have piped line in bash script and want to check if pipe has data, before feeding program Searching I found about test -t 0 but it doesn't work here. Always returns false. So how to be sure that pipe has data? I'm providing example: echo "string" | [ -t 0 ] && echo "empty" || echo "fill" output: fill echo "string" | tail -n+2 | [ -t 0 ] && echo "empty" || echo "fill" output: fill (HowTos)