27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

echo; echo<br />

escape=$'\033'<br />

# 033 is octal for escape.<br />

echo "\"escape\" echoes as $escape"<br />

# no visible output.<br />

echo; echo<br />

exit 0<br />

\"<br />

\$<br />

\\<br />

See Example 35−1 for another example of the $' ' string expansion construct.<br />

gives the quote its literal meaning<br />

echo "Hello"<br />

# Hello<br />

echo "\"Hello\", he said." # "Hello", he said.<br />

gives the dollar sign its literal meaning (variable name following \$ will not be referenced)<br />

echo "\$variable01" # results in $variable01<br />

gives the backslash its literal meaning<br />

echo "\\" # results in \<br />

The behavior of \ depends on whether it is itself escaped, quoted, or appearing within command<br />

substitution or a here document.<br />

# Simple escaping and quoting<br />

echo \z<br />

# z<br />

echo \\z # \z<br />

echo '\z' # \z<br />

echo '\\z'<br />

# \\z<br />

echo "\z" # \z<br />

echo "\\z" # \z<br />

# Command substitution<br />

echo `echo \z` # z<br />

echo `echo \\z` # z<br />

echo `echo \\\z` # \z<br />

echo `echo \\\\z` # \z<br />

echo `echo \\\\\\z` # \z<br />

echo `echo \\\\\\\z` # \\z<br />

echo `echo "\z"` # \z<br />

echo `echo "\\z"` # \z<br />

# Here document<br />

cat

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!