Here Documents
Ouput has '>' and '>>'. Now that you've seen '<', what about '<<'?
Actually,
If you want to imbed the contents of a file into a script, a here document is a good way to do it.
As usual, you should try out moving around the redirects, and use command history to do it.
There's even a '<<<'
This is a here document, which says "Take input from from 'here to FOO'"cat <<FOO
hello world
FOO
Actually,
FOO
can be a little visually confusing, because I often use FOO
and foo
for variable or file names, so I usually use a marker for "End of Input" or "End of File" instead, like __EOF__
or __EOI__
. These stand out and I don't use them for other things.If you want to imbed the contents of a file into a script, a here document is a good way to do it.
As usual, you should try out moving around the redirects, and use command history to do it.
There's even a '<<<'
It's sort of a "right here" document, which provides input from the current line.H='hello, world'
cat <<< $H
0 Comments:
Post a Comment
<< Home