Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!princeton!grendel.Princeton.EDU From: rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) Newsgroups: comp.unix.shell Subject: Piping here documents Message-ID: <6061@idunno.Princeton.EDU> Date: 8 Feb 91 01:15:43 GMT Sender: news@idunno.Princeton.EDU Organization: Princeton University, Princeton, New Jersey Lines: 22 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