Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:23:38+00:00 2026-06-17T21:23:38+00:00

How to made bash to execute variable value. For example, we have this code,

  • 0

How to made bash to execute variable value.
For example, we have this code, where variable value was set in single quotes(!).

#!/bin/bash
V_MY_PATH='$HOME'
echo "$V_MY_PATH"
ls $V_MY_PATH

The output is

$HOME
ls: $HOME: No such file or directory

How to made bash to translate shell variable insto its value if there is some.

I want to add some code after V_MY_PATH=’$HOME’ to make output like echo $HOME.

It’s something simple, but i’m stuck.
(NB: I know that with V_MY_PATH=”$HOME”, it works fine.)

EDIT PART:
I just wanted to make it simple, but I feel that some details are needed.

I’m getting parameter from a file. This part works good. I don’t want to rewite it.
The problem is that when my V_MY_PATH contains a predefined variable (like $home) it’s not treated like its value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:23:40+00:00Added an answer on June 17, 2026 at 9:23 pm

    use variable indirect reference so:

    pete.mccabe@jackfrog$ p='HOME'
    pete.mccabe@jackfrog$ echo $p
    HOME
    pete.mccabe@jackfrog$ ls ${p}
    ls: cannot access HOME: No such file or directory
    pete.mccabe@jackfrog$ ls ${!p}
    bash                        libpng-1.2.44-1.el6      python-hwdata           squid
    ...
    pete.mccabe@jackfrog$ 
    

    The ${!p} means take the value of $p and that value is the name of the variable who’s contents I wish to reference

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a script to open Spotify with wine: #!/bin/bash DIR=/home/jorgsk/.wine/drive_c/Program Files/Spotify/ cd
I'm made the following code to determine if a process is running: #!/bin/bash ps
While trying something similar in a bash script I made this snippet: #!/bin/bash your_animal=fishies
I'm not experienced with shell scripting. I made this: #!/bin/bash function hac() { echo
I have made Bash scripts before and they all ran fine without #!/bin/bash at
I found this nice little script that I've made into a bash script. #!/bin/bash
I made this bash one-liner which I use to list Weblogic instances running along
I fixed the code below so it works: #!/bin/bash out=$(cat /proc/acpi/bbswitch) if [[ $out
I have made a bash file which launches another bash file in a detached
I have this line in bash: echo a=-1|perl -nle 'if (/.*=[0-9]*/){print;}' and get: a=-1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.