Hey all,

I have a dumb question to ask :(..

I want to know how to create a shell script that reads input from the STDIN as default, but when [-o inputFile] is entered as an option, it will read the input from the inputFile. I want to do this in a way that doesn't need to duplicate code for each case....

Thank you so much for your help.. Regards...

Hey all,

I have a dumb question to ask :(..

I want to know how to create a shell script that reads input from the STDIN as default, but when [-o inputFile] is entered as an option, it will read the input from the inputFile. I want to do this in a way that doesn't need to duplicate code for each case....

case $1 in
     -o) shift ;;
     *)  set -- /dev/stdin ;;
esac

while IFS= read -r
do
  : do whatever with "$line"
done < "$1"

Thank you so much that really helped!...