Complete.Org: Mailing Lists: Archives: linux-help: January 2002:
[linux-help] Re: multi-line output from Bourne shell

[linux-help] Re: multi-line output from Bourne shell

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: multi-line output from Bourne shell
From: Tom Hull <thull@xxxxxxxxxxx>
Date: Mon, 07 Jan 2002 12:27:24 -0600
Reply-to: linux-help@xxxxxxxxx

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

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

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 *
-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,

[Prev in Thread] Current Thread [Next in Thread]