Piping here documents

Robert Lupton the Good rhl at grendel.Princeton.EDU
Fri Feb 8 12:15:43 AEST 1991


What's the best way of piping a here document into a long shell script?
For a one liner
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/bin/sh
cat <<-EOF | sed -e s/Hello/Goodbye/
	Hello world
EOF
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
works just fine, but if the rest of the commands (here just sed) don't
fit on a line this doesn't work. The best that I could come up with was:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/bin/sh
if true; then
cat <<-EOF
	Hello world
EOF
fi | sed -e s/Hello/Goodbye/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Any ideas?

				Robert



More information about the Comp.unix.shell mailing list