Can sh or csh do this VMS DCL trick??
0152
graf21 at unibi.uni-bielefeld.de
Fri May 3 03:55:33 AEST 1991
In article <1991Apr28.003414.26784 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
>
>Sounds like you want the ``here-is'' notation:
>
> cat >post_news.txt <<EOD
> blah blah
> ... etc ..
> EOD
>
My favourite way of using "here-documents" is
to to pipe the "document" into the desired command through an
intermediate "sed", like this:
sed 's/^\.//' | your-command -options args <<EOD
.
.This is the input to "your-command", starting with a blank line
.and ending with another one
.
EOD
next-command ...
Some "shar"-archivers (not all, unfortunately) use this trick. By
specifying different patterns you could even introduce line-numbering,
comments, indentation etc. into a "here-document". (sh ignores indentation
when EOD is preceded by a minus sign, anyway.) Apart from improving
readability, there can't possibly be confusion between the "EOD" line
ending the input and a similar line inside it. The pattern after
"sed 's/" must be designed carefully and "anchored" via "^" to make
sure that "sed" delete no more characters from the input than intended.
Sebastian Lisken
Bielefeld University, Germany
More information about the Comp.unix.questions
mailing list