Linux Bash Scripting: Declare var name from user or file input -
hi following.
./script.sh some.file.name.dat another.file.dat filename1=$(echo "$1"|cut -d '.' -f 1,2) filename2=$(echo "$2"|cut -d '.' -f 1,2) tempfile_"$1"=$(mktemp) tempfile_"$2"=$(mktemp)
i know code isn't working. need create these temporary files , use them in loop later, in input files , save output in these temporary files later usage. create variable names dependent on name of input files.
i googled lot , didn't found answers problem.
i thank suggestions
you cannot since bash doesn't allow dots in names of identifiers/variables. both of arguments $1
, $2
have dots (periods) in them , cannot used in variable names you're trying create i.e. tempfile_$1
see this page details.
Comments
Post a Comment