I'm new to bash programming and struggling with this one portion of my program. I know how to use positional parameters in order to refer to certain elements of the command line, however, I can only get this to work if a file is specified. How can I use positional parameters with standard input like so:
cat test_file | stats -r
In this instance, I can refer to stats with "$0" and -r with "$1" but how can I refer to the cat test_file part? For context, Stats is my program which finds the average and median of the numbers in test file. "-r' indicates that the program should read each row of the program. When the command line is written like this:
stats -r test_file
I use this code to denote the -r
if [[ "${1:0:2}" == '-r' ]]
do stuff