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









                  KusalanandaKusalananda

                  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

                              Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

                              Frič See also Navigation menuinternal link

                              Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant