[linux-help] Re: multi-line output from Bourne shell
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Thanks once again, Tom. I knew that there had to be a simple, elegant
solution that was just beyond the edge of my knowledge. I also
seemed to remember that Perl had gotten the here file feature from
somewhere else. I didn't know that it would work with any command
that needs mulitiple lines of input, however. I'm glad you mentioned
that tidbit.
John
>John Reinke wrote:
>>
>> What would be the best way in the Bourne shell (not bash!) to do the
>> equivelant of Perl's 'print <<END_OF_TEXT;'?
>>
>> I need to generate a file from a Bourne shell script, and there are
>> several large portions of the file that will be the same every time. It
>> wouldn't be feasible to 'echo "one line of text" >> output_file' for every
>> line in the file. Also, the script probably won't have access to other
>> files, so appending the contents of separate existing files won't work.
>
>cat <<EOF
>Type in all the
>text you want, as
>many lines as you want,
>plus you can expand $Variables
>and even run `date`, pretty
>much anything you can do in ""
>except having to escape \",
>until you hit a line with
>nothing but EOF on it
>EOF
>
>If you want to pipe this file, add the pipe commands after the <<EOF
>(EOF is convention, anything will do), e.g.:
>
>cat <<EOF | tr a-z A-Z
>hello world
>goodbye world
>EOF
>
>cat just copies stdin to stdout; use any other program that reads stdin
>to whatever effect you're looking for.
>
>> Thanks,
>> John
>
>--
>/*
> * Tom Hull * thull at kscable.com * http://www.tomhull.com/
> */
-- This is the linux-help@xxxxxxxxx list. To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
|
|