So i recently noticed that, when declaring a variable using a command substitution, let's say like so:
var=$(echo "this is running" > test; cat test)
Then it will run (the file
test will be created) , even though i didn't yet called it (technically), which i would like so:
var=$(echo "this is running" > test; cat test) echo "$var" # is where i would "normally" call the variable
How could I prevent the command substitution from actually running when declaring it in a variable, so it only actually run when I call the said variable?
PS: Well aware this is kind of a bad example, but it serve well to demonstrate what i mean, although with "useless use of cat" and "useless use of echo"...