0

This question already has an answer here:

I have this which won't work:

source_dir=`cd `dirname `readlink "$BASH_SOURCE"`` && pwd`;

what does work is this tho:

source_dir=$(cd $(dirname $(readlink "$BASH_SOURCE")) && pwd);

is there a way to use backticks instead?

marked as duplicate by John1024 bash May 10 at 0:01

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.

  • 1
    Only use one pair? Or just use $()? Why do you need back ticks? – Jeff Schaller May 9 at 23:26
  • Are backticks equivalent to "$()" or $()? if the former they save a lot of space – Alexander Mills May 9 at 23:27
  • 2
  • 2
    The accepted answer in @JeffSchaller's link explains how to nest backticks. But, don't do that: use $(...) instead because, especially when nested, $(...) is much easier to read and comprehend. – John1024 May 10 at 0:03
  • Also, backticks are equivalent to an unquoted $(). – John1024 May 10 at 5:20