0

Is there a way to use ` inside a ` in bash script

This works

echo `echo '(!1)*2' | bc -l`

but this doesnt

echo `echo '(!`echo 1`)*2' | bc -l`

the error is

unmatched '

how do I fix this?

pineapple
  • 3
  • 1

1 Answers1

2

You can make use of $() instead of ``:

$ echo $(echo $(echo $(echo "Hello") world)! )

Or the solution to your answer:

$ echo $(echo "( ! $(echo 1) )*2" | bc -l)

p.s. don't use ' when you want to make use of variables inside a string. Only double quotes " are parsed.

Bayou
  • 3,293
  • 1
  • 9
  • 22