Create parameters for command Linux shell script -
hello trying create parameters shell script having trouble.
lets example file called test.
when call ./test -parameter1 input_file.txt error saying 'no such file or directory'.
here example of code.
#!/bin/sh if [ "$1" == "parameter" ] while read line #echo "$line" done <$1 else echo "not working" fi my on goal of read in file of numbers line line have working, calculate average values of rows or columns. why trying create parameters user have specify ./test -rows input_file.txt or ./test -columns input_file.txt
you using string -parameter input file name. perhaps want:
#!/bin/sh if [ "$1" = "-parameter" ] while read line #echo "$line" done <$2 # use $2 instead of $1 here. or use shift else echo "not working" >&2 fi
Comments
Post a Comment