how to specify an command line argument with a variable in bash -
i bash script take either 2 or 3 arguments last argument being input file open. index of argument should depend on how many arguments provided. know can realized if statement, like:
if [ $# -eq 3 ]; infile=$3 elif [ $# -eq 2 ]; infile=$2 fi ..open file read...
however hoping done 1 liner this:
infile=$($#) it not work though. same thing infile=$"$#". possible specify index of argument directly "$#"
try using infile="${@: -1}" last argument.
Comments
Post a Comment