I have a script that takes several arguments.
Now I modified the script to exclude multiple file names and work with them.
I also want this script to be executed when I get input through a pipe (|) or redirected input (<). But I do not want the script to wait for input on the terminal when none of the above three inputs is provided, but rather shows instructions for use.
I am using the following function:
# PIPED CONTENT if [ "$#" == "0" ]; then READINPUT="1" if [ "x$TEXTINPUT" == x"" ]; then READINPUT=1 TMPFL=`tempfile -m 777` while read data; do echo "${data}" >> $TMPFL done TEXTINPUT="`cat $TMPFL`" rm $TMPFL fi # if [ "x$TEXTINPUT" == x"" ]; then # if [ "$#" == "0" ]; then usage; fi # fi fi
Any help is appreciated.
Yours faithfully
Nikhil Gupta
source share