Friday, 15 August 2014

shell - How to redirect / link variables in bash? -



shell - How to redirect / link variables in bash? -

i trying linking variables in bash script (three or more). example:

read -e -p "enter 5' restriction enzyme:" re5

i expect user come in "bamhi", , link user input (bamhi) text string, ("ggatcc"). don't know if user input lower or upper case, right use:

re5l=`echo "$re5" | tr '[:upper:]' '[:lower:]'`

and set:

bamhi=ggatcc

now when come in echo $re5l bamhi , ggatcc

but don't know how or wrong. suggestions, correction or way welcome. give thanks in advance.

the reply @gniourf_gniourf improve practice, , should take , use. beingness provided because it's more direct reply question.

almost you're doing fine:

read -e -p "enter 5' restriction enzyme:" re5 re5l=${re5,,} bamhi=ggatcc

...but if want honor indirection in lookup, utilize ! character so:

echo "${!re5l}"

...instead of

echo "${re5l}"

bash shell variables echo

No comments:

Post a Comment