Article View: comp.unix.shell
Article #1787Re: How do you pipe after a here document
From: Jim Rogers
Date: Tue, 13 Nov 1990 17:32
Date: Tue, 13 Nov 1990 17:32
33 lines
1090 bytes
1090 bytes
Another approach is to use functions in your shell:
(This example works in KSH also)
#!/bin/sh
# create a function to pipe to, if you want
write_it () {
bold=`tput bold`
while read words
do
echo "${bold}${words}"
done
}
#Place the here document inside a function. The results of the function
#can be piped to any process which reads from stdin.
here_cat () {
cat << BYE
This is
the test
of the use
of a HERE
document
in the SH
BYE
}
# Invoke the "here function" and pipe its output to something.
here_cat | write_it
Jim Rogers
Hewlett Packard Company
Technical Details
Message-ID:
<27620008@hp-lsd.COS.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!wuarchive!swbatl!synoptics!unix!hplabs!hpcc05!col!hpldola!hp-lsd!jimrReferences:
<1990Nov8.201508.13222@cid.aes.doe.CA>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!wuarchive!swbatl!synoptics!unix!hplabs!hpcc05!col!hpldola!hp-lsd!jimr From: jimr@hp-lsd.COS.HP.COM (Jim Rogers) Newsgroups: comp.unix.shell Subject: Re: How do you pipe after a here document Message-ID: <27620008@hp-lsd.COS.HP.COM> Date: 13 Nov 90 17:32:33 GMT References: <1990Nov8.201508.13222@cid.aes.doe.CA> Organization: HP Logic Systems Division - ColoSpgs, CO Lines: 33