I have the variable $foo="something"
and would like to use:
bar="foo"; echo $($bar)
to get "something" echoed.
bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.
There are no Booleans in Bash. However, we can define the shell variable having value as 0 (“ False “) or 1 (“ True “) as per our needs.
$0 is the name of the script itself (script.sh) $1 is the first argument (filename1) $2 is the second argument (dir1)
In bash, you can use ${!variable}
to use variable variables.
foo="something" bar="foo" echo "${!bar}" # something
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With