How to Determine the Source of Shell Input?

view full story

http://lpilinux.com – After a bit of pondering I came up with two solutions: the stat command and using information from the proc file system. The first solution uses the stat command to determine what type of file is connected to standard input. First we find out what is connected to standard input: stdin=”$(ls -l /dev/fd/0)” stdin=”${stdin/*-> /}” The file /dev/fd/0 is the standard input, which is a symbolic link. So we use ls to get the (HowTos)