[TriLUG] solved: HERE document question
Joseph Mack NA3T
jmack at wm7d.net
Tue Jul 27 14:19:37 EDT 2010
On Mon, 26 Jul 2010, Kevin Hunter wrote:
> Since no one seems to be stepping forward with a "Here's
> your answer, Joe!", may I suggest you post your script in
> it's entirety to a pastebin service, and let folks take a
> look. Explanations are great, but sometimes there's no
> substitute for code.
I did it by brute force. I needed the generating script to
sometimes substitute the value of a variable in the
HERE document. You do this with
partition=/dev/sda1
cat > $filename <<EOF
echo "$partition"
EOF
when $filename will contain
echo "/dev/sda1"
Sometimes I needed the name of the variable, and not the
value, in the HERE document. You do this with
cat $filename> <<\EOF
if [ "$count" = "0" ]
EOF
when $filename will contain
if [ "$count" = "0" ]
I couldn't find any finer control of whether a variable
would be substituted or written as is. I wrote the
generating script to piecewise output strings as 5 separate
HERE documents (some with variables substituted and some
wrtten literally) which were cat'ed into the final file.
Thanks Joe
--
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
More information about the TriLUG
mailing list