Monday, January 31, 2011

BASH : Quoting Nuances

2 types - strong quoting and normal quoting
echo this is a test
echo I want money $ -> prints 'I want money $'
echo I want money $sum -> prints 'I want money'
echo I want money \$sum -> prints 'I want money $sum' -> '\'-backslash
mkdir space directory -> create 2 directories
rm -rf space directory -> deletes the 2 above directories
mkdir space\ directory -> create 1 directorie
echo "this is a test $" -> print 'this is a test $'
echo "this is a test $1" -> print 'this is a test'
echo "this is a test $?" -> print 'this is a test 0'
echo 'this is a test $1' -> print 'this is a test $1'
echo 'this is a test $1 \' -> print 'this is a test $1 \'
echo "keep the backslash $ \\" -> prints 'keep the backslash $ \'

No comments:

Post a Comment