Bash Input/Output: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 30: Line 30:
) > /tmp/test.txt
) > /tmp/test.txt
</pre>
</pre>
=Iterating over Lines in the Same bash Process=
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[Bash_for#Iterating_over_Lines_in_the_Same_bash_Process|Iterating over Lines in the Same bash Process]]
</blockquote>

Revision as of 00:36, 1 March 2016

Internal

Echo Multiple Lines to stdout

cat <<EOF
  blah
  ${some_var}
  blah
EOF
  • It will perform variable substitution. If you don't want that, escape \${some_var}.
  • `...` sequences should be escaped as shown here: \`...\` otherwise they will executed before the output is sent to stdout.
  • \ will join lines. If you want "\" in the output, then you should escape it:
      ...
      blah blah \\
      ...

Echo Multiple Lines into a File

(cat << EOF
blah
EOF
) > /tmp/test.txt

Iterating over Lines in the Same bash Process

Iterating over Lines in the Same bash Process