Linux ECHO output of a ECHO variable [duplicate]Indirectly access environment variableHow can I run growisofs via sudo?Need to set a variable with “[]”list files and store it in variablesAssign Subshell background process pid to variableHow to echo makefile variable through Make's $(shell …)Issues with storing an echo of a date conversion into a string variable inunixGet specific result from functionscript set command output to variableDifference between 'cat < file.txt' and 'echo < file.txt'Declaring a variable that does not have inputPutting external IP into a variable - grep operation failed

Is this apparent Class Action settlement a spam message?

Two monoidal structures and copowering

Roman Numeral Treatment of Suspensions

How do I find the solutions of the following equation?

How to Reset Passwords on Multiple Websites Easily?

How did Arya survive the stabbing?

How do I extract a value from a time formatted value in excel?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

Gears on left are inverse to gears on right?

What happens if you roll doubles 3 times then land on "Go to jail?"

Is expanding the research of a group into machine learning as a PhD student risky?

when is out of tune ok?

What is the difference between "behavior" and "behaviour"?

Anatomically Correct Strange Women In Ponds Distributing Swords

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Increase performance creating Mandelbrot set in python

Is there a good way to store credentials outside of a password manager?

Sort a list by elements of another list

How easy is it to start Magic from scratch?

Is HostGator storing my password in plaintext?

Is exact Kanji stroke length important?

Return the Closest Prime Number

Why, precisely, is argon used in neutrino experiments?

What is the best translation for "slot" in the context of multiplayer video games?



Linux ECHO output of a ECHO variable [duplicate]


Indirectly access environment variableHow can I run growisofs via sudo?Need to set a variable with “[]”list files and store it in variablesAssign Subshell background process pid to variableHow to echo makefile variable through Make's $(shell …)Issues with storing an echo of a date conversion into a string variable inunixGet specific result from functionscript set command output to variableDifference between 'cat < file.txt' and 'echo < file.txt'Declaring a variable that does not have inputPutting external IP into a variable - grep operation failed













0
















This question already has an answer here:



  • Indirectly access environment variable [duplicate]

    3 answers



I have a variable (var) which return value as VAR1 ($var has the value VAR1).
There is an input file which has VAR1 defined (VAR1=ABCDEF)



How can I use echo to get the value ABCDEF using $var??



I tried echo $(echo $var) and many other options, but I always get output as VAR1 or echo VAR1 but never ABCDEF. I used source in file with VAR1 declared, tried in command prompt etc.










share|improve this question









New contributor




shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Kusalananda♦, DopeGhoti, jimmij, nwildner, muru 2 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















    0
















    This question already has an answer here:



    • Indirectly access environment variable [duplicate]

      3 answers



    I have a variable (var) which return value as VAR1 ($var has the value VAR1).
    There is an input file which has VAR1 defined (VAR1=ABCDEF)



    How can I use echo to get the value ABCDEF using $var??



    I tried echo $(echo $var) and many other options, but I always get output as VAR1 or echo VAR1 but never ABCDEF. I used source in file with VAR1 declared, tried in command prompt etc.










    share|improve this question









    New contributor




    shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.











    marked as duplicate by Kusalananda♦, DopeGhoti, jimmij, nwildner, muru 2 hours ago


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      0












      0








      0









      This question already has an answer here:



      • Indirectly access environment variable [duplicate]

        3 answers



      I have a variable (var) which return value as VAR1 ($var has the value VAR1).
      There is an input file which has VAR1 defined (VAR1=ABCDEF)



      How can I use echo to get the value ABCDEF using $var??



      I tried echo $(echo $var) and many other options, but I always get output as VAR1 or echo VAR1 but never ABCDEF. I used source in file with VAR1 declared, tried in command prompt etc.










      share|improve this question









      New contributor




      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.













      This question already has an answer here:



      • Indirectly access environment variable [duplicate]

        3 answers



      I have a variable (var) which return value as VAR1 ($var has the value VAR1).
      There is an input file which has VAR1 defined (VAR1=ABCDEF)



      How can I use echo to get the value ABCDEF using $var??



      I tried echo $(echo $var) and many other options, but I always get output as VAR1 or echo VAR1 but never ABCDEF. I used source in file with VAR1 declared, tried in command prompt etc.





      This question already has an answer here:



      • Indirectly access environment variable [duplicate]

        3 answers







      variable echo






      share|improve this question









      New contributor




      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday









      Kusalananda♦

      138k17258426




      138k17258426






      New contributor




      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      shashank barkishashank barki

      41




      41




      New contributor




      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      shashank barki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      marked as duplicate by Kusalananda♦, DopeGhoti, jimmij, nwildner, muru 2 hours ago


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Kusalananda♦, DopeGhoti, jimmij, nwildner, muru 2 hours ago


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes


















          6














          Assuming that you are using the bash shell:



          $ source ./file
          $ echo "$VAR1"
          ABCDEF
          $ var=VAR1
          $ echo "$!var"
          ABCDEF


          By using $!var you use variable indirection in bash. The value of the variable var is used to get the name of the variable to expand.




          In bash you could also use a name reference variable:



          $ source ./file
          $ echo "$VAR1"
          ABCDEF
          $ declare -n var="VAR1"
          $ echo "$var"
          ABCDEF


          Here, the var variable refers to the VAR1 variable, so $var will expand to whatever $VAR1 expands to.



          Name references are originally a ksh feature, and in that shell they are declare with typeset -n.



          Name references are extremely useful fo passing references to arrays in calls to shell functions.




          In any sh shell:



          $ . ./file
          $ echo "$VAR1"
          ABCDEF
          $ var=VAR1
          $ eval "echo "$$var""
          ABCDEF


          The eval utility takes a string which it will re-evaluate. Here, we give it the string echo "$VAR1" (after expansion of $var).



          The issue with eval is that it's easy to introduce errors or vulnerabilities with it, by carelessly creating its argument string.






          share|improve this answer
































            3














            Assuming you are using bash, you can accomplish this easily with an indirect reference:



            $ foo=bar
            $ bar=magicword
            $ printf "%sn" "$!foo"
            magicword


            The syntax $var (or $var) yields the contents of the variable var.



            The syntax $!var yields the contents of the variable named in var.






            share|improve this answer































              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              6














              Assuming that you are using the bash shell:



              $ source ./file
              $ echo "$VAR1"
              ABCDEF
              $ var=VAR1
              $ echo "$!var"
              ABCDEF


              By using $!var you use variable indirection in bash. The value of the variable var is used to get the name of the variable to expand.




              In bash you could also use a name reference variable:



              $ source ./file
              $ echo "$VAR1"
              ABCDEF
              $ declare -n var="VAR1"
              $ echo "$var"
              ABCDEF


              Here, the var variable refers to the VAR1 variable, so $var will expand to whatever $VAR1 expands to.



              Name references are originally a ksh feature, and in that shell they are declare with typeset -n.



              Name references are extremely useful fo passing references to arrays in calls to shell functions.




              In any sh shell:



              $ . ./file
              $ echo "$VAR1"
              ABCDEF
              $ var=VAR1
              $ eval "echo "$$var""
              ABCDEF


              The eval utility takes a string which it will re-evaluate. Here, we give it the string echo "$VAR1" (after expansion of $var).



              The issue with eval is that it's easy to introduce errors or vulnerabilities with it, by carelessly creating its argument string.






              share|improve this answer





























                6














                Assuming that you are using the bash shell:



                $ source ./file
                $ echo "$VAR1"
                ABCDEF
                $ var=VAR1
                $ echo "$!var"
                ABCDEF


                By using $!var you use variable indirection in bash. The value of the variable var is used to get the name of the variable to expand.




                In bash you could also use a name reference variable:



                $ source ./file
                $ echo "$VAR1"
                ABCDEF
                $ declare -n var="VAR1"
                $ echo "$var"
                ABCDEF


                Here, the var variable refers to the VAR1 variable, so $var will expand to whatever $VAR1 expands to.



                Name references are originally a ksh feature, and in that shell they are declare with typeset -n.



                Name references are extremely useful fo passing references to arrays in calls to shell functions.




                In any sh shell:



                $ . ./file
                $ echo "$VAR1"
                ABCDEF
                $ var=VAR1
                $ eval "echo "$$var""
                ABCDEF


                The eval utility takes a string which it will re-evaluate. Here, we give it the string echo "$VAR1" (after expansion of $var).



                The issue with eval is that it's easy to introduce errors or vulnerabilities with it, by carelessly creating its argument string.






                share|improve this answer



























                  6












                  6








                  6







                  Assuming that you are using the bash shell:



                  $ source ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ var=VAR1
                  $ echo "$!var"
                  ABCDEF


                  By using $!var you use variable indirection in bash. The value of the variable var is used to get the name of the variable to expand.




                  In bash you could also use a name reference variable:



                  $ source ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ declare -n var="VAR1"
                  $ echo "$var"
                  ABCDEF


                  Here, the var variable refers to the VAR1 variable, so $var will expand to whatever $VAR1 expands to.



                  Name references are originally a ksh feature, and in that shell they are declare with typeset -n.



                  Name references are extremely useful fo passing references to arrays in calls to shell functions.




                  In any sh shell:



                  $ . ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ var=VAR1
                  $ eval "echo "$$var""
                  ABCDEF


                  The eval utility takes a string which it will re-evaluate. Here, we give it the string echo "$VAR1" (after expansion of $var).



                  The issue with eval is that it's easy to introduce errors or vulnerabilities with it, by carelessly creating its argument string.






                  share|improve this answer















                  Assuming that you are using the bash shell:



                  $ source ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ var=VAR1
                  $ echo "$!var"
                  ABCDEF


                  By using $!var you use variable indirection in bash. The value of the variable var is used to get the name of the variable to expand.




                  In bash you could also use a name reference variable:



                  $ source ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ declare -n var="VAR1"
                  $ echo "$var"
                  ABCDEF


                  Here, the var variable refers to the VAR1 variable, so $var will expand to whatever $VAR1 expands to.



                  Name references are originally a ksh feature, and in that shell they are declare with typeset -n.



                  Name references are extremely useful fo passing references to arrays in calls to shell functions.




                  In any sh shell:



                  $ . ./file
                  $ echo "$VAR1"
                  ABCDEF
                  $ var=VAR1
                  $ eval "echo "$$var""
                  ABCDEF


                  The eval utility takes a string which it will re-evaluate. Here, we give it the string echo "$VAR1" (after expansion of $var).



                  The issue with eval is that it's easy to introduce errors or vulnerabilities with it, by carelessly creating its argument string.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited yesterday

























                  answered yesterday









                  Kusalananda♦Kusalananda

                  138k17258426




                  138k17258426























                      3














                      Assuming you are using bash, you can accomplish this easily with an indirect reference:



                      $ foo=bar
                      $ bar=magicword
                      $ printf "%sn" "$!foo"
                      magicword


                      The syntax $var (or $var) yields the contents of the variable var.



                      The syntax $!var yields the contents of the variable named in var.






                      share|improve this answer





























                        3














                        Assuming you are using bash, you can accomplish this easily with an indirect reference:



                        $ foo=bar
                        $ bar=magicword
                        $ printf "%sn" "$!foo"
                        magicword


                        The syntax $var (or $var) yields the contents of the variable var.



                        The syntax $!var yields the contents of the variable named in var.






                        share|improve this answer



























                          3












                          3








                          3







                          Assuming you are using bash, you can accomplish this easily with an indirect reference:



                          $ foo=bar
                          $ bar=magicword
                          $ printf "%sn" "$!foo"
                          magicword


                          The syntax $var (or $var) yields the contents of the variable var.



                          The syntax $!var yields the contents of the variable named in var.






                          share|improve this answer















                          Assuming you are using bash, you can accomplish this easily with an indirect reference:



                          $ foo=bar
                          $ bar=magicword
                          $ printf "%sn" "$!foo"
                          magicword


                          The syntax $var (or $var) yields the contents of the variable var.



                          The syntax $!var yields the contents of the variable named in var.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited yesterday

























                          answered yesterday









                          DopeGhotiDopeGhoti

                          46.6k56190




                          46.6k56190













                              -echo, variable

                              Popular posts from this blog

                              2017 IndyCar Series Contents Series news Teams and drivers Schedule Season summary Footnotes References External links Navigation menu"INDYCAR: Initial 2018 bodywork concepts unveiled"the original"IndyCar confirms switch to Performance Friction brakes in 2017""AJ Foyt Racing will switch to Chevy"the original"Carlos Munoz, Conor Daly will drive for AJ Foyt Racing""Zach Veach's Indy 500 Debut Confirmed with Foyt""No mass exodus from Honda after Ganassi switch""Ex-F1 driver Sato joins Andretti Autosport for 2017 IndyCar season""IndyCar's Ryan Hunter-Reay, sponsor DHL paired through 2020""hhgregg and Andretti Autosport announce partnership for key races in 2016""INDYCAR: Rossi re-signs with Andretti"the original"McLaren Formula 1 - Fernando Alonso to race at Indy 500 with McLaren, Honda and Andretti Autosport""Shank will finally take part in Indy 500 with Harvey, Andretti | MotorSportsTalk""Andretti adds Jack Harvey to Indy 500 field""Ganassi switches to Honda power for 2017""INDYCAR: Chilton returns to Ganassi"the original"IndyCar silly season: Who's going where in 2017?""INDYCAR: Kanaan, NTT Data return to Ganassi"the original"Kimball to remain at Ganassi for 2017""Coyne confirms Bourdais for 2017 IndyCar season""Davison to sub for Bourdais in Indy 500"the original"Gutierrez confirmed for Detroit IndyCar debut""Gutierrez returns with Coyne for rest of 2017 season""Vautier to drive for Coyne at Texas"the original"INDYCAR: Coyne confirms Jones for 2017"the original"Pippa Mann returns to Coyne for Indy 500""Karam, Dreyer & Reinbold teaming up again for Indianapolis 500""Pigot to return to Ed Carpenter Racing""Hildebrand confirmed as full-time Ed Carpenter driver""Veach to replace injured Hildebrand at Barber"the originalNew Team Harding Racing Enters Chaves for 101st Indianapolis 500"Juncos Racing Announces Entry in 101st Running of the Indianapolis 500 :: Juncos Racing""Juncos confirms Pigot for Indy 500""Saavedra confirmed in Juncos' second 500 entry"the original"Lazier confirms Indy 500 run after son's USF2000 debut"the original"Claman DeMelo to race for RLLR at Sonoma"the original"Rahal signs Servia and ace engineer for 2017""IndyCar: Aleshin returns with Schmidt"the original"Aleshin replaced by Saavedra for Toronto""Jack Harvey will pilot SPM No. 7 car at Watkins Glen, Sonoma""Jay Howard confirmed in Tony Stewart's supported SPM Indy entry""INDYCAR: Newgarden to wave the flag at Penske"the original"Pagenaud opts for No. 1 in 2017"the original"Penske confirms Newgarden for 2017""Montoya to stay with Team Penske in 2017""Target leaving IndyCar after 27 seasons with Chip Ganassi""Cavin: IndyCar could see complete driver/team shakeup in 2017""End of the road for KV Racing?""KV Racing confirms closure, equipment sold to Juncos""Juncos confirms IndyCar Series entry"the original"Juncos readies IndyCar program, aims for '17 500"the original"Harding Racing to add Texas, Pocono to schedule"the original"Sato signs with Andretti Autosport for 2017""INDYCAR: Aleshin in Doubt at SPM"the original"Long Beach notebook: JR Hildebrand breaks hand""Hildebrand cleared to return at Phoenix"the original"Bourdais to undergo surgery on multiple fractures""Aleshin loses Schmidt Peterson IndyCar ride""Saavedra in at SPM for Pocono, Gateway"the original"Bourdais to make return at Gateway"the original"The IndyCar Grand Prix no longer is sponsored by Angie's List""2017 IndyCar Series rulebook""2017 Verizon IndyCar Series Official Rulebook"Official websiteeeeee

                              Word for a person who has no opinion about whether god existsWord for having a definite opinion while simultaneously withholding judgment?What's the opposite of “newcomer? Is ”veteran" OK?What do you call an “atheist” who might believe in an afterlife?What's a word for someone who wants to voice opinions but not have them challenged?Word for someone who dismisses contrary opinions as irrational?Somone who thinks they are overly special/out of the ordinaryIs there a word, phrase or idiom for “a person who is incapable of thinking about the future”?The belief that a god is human-likeA word for a non-famous person/thing you have heard a lot aboutAdjective for a person who enjoys taking care of their appearance

                              Can I sign legal documents with a smiley face?Do Legal Documents Require Signing In Standard Pen Colors?Is it possible to legally prohibit someone from linking to specific pages on your website?Do scans of signed documents have the same legal power as the original document?What can I do if I signed an excessively restrictive contract?Can other party sneak in new contract terms via termination notice?How to prove that someone forged my signature on a contract that I was not aware of?In Australia, Is it legal to sign a document as somebody else?making a contract that includes video licenceLease dispute, over email and text messageIf you must include all of the natural language prose in a legal document, or if it can be abstracted outE-signing: legal ramifications of “identifying” a person