Monday, September 3, 2012

What is the substitute to backticks?

"$( )" is the substitute to backticks (``) with an advantage of nesting commands without escapes and better readability. The only bottleneckness $( ) suffers from is lack of portability.

For Example,

VAR=`date +%D`
echo "The date is: $VAR"

or

echo "The date is: `date +%D`"

The above lines can be replaced with the following one :

echo "The date is: $(date +%D)"

No comments :