[Techtalk] ed < file

Malcolm Tredinnick malcolm at commsecure.com.au
Wed Nov 13 22:40:19 EST 2002


On Wed, Nov 13, 2002 at 09:40:27AM +0100, Dan Richter wrote:
> >The above command has the effect of passing lots of different arguments
> >to ed, no passing it stuff on stdin.
> <snip>
> >What you want to do is:
> >
> >(cat <<EOF; ) | ed filename
> >1,$s/foo/bar/g
> >w
> >q
> >EOF
> 
> I don't get this. Isn't "cat" reading from stdin in this example? "cat" 
> with a command-line argument refers to a file. So why is it stdin for "cat" 
> and not for "ed"?

Err .. yeah. :-(

You are correct and I am completely wrong. The 'ed' example should work.
An in fact, if file 'foo' contains 

	cat
	dog
	elephant

then running

	ed foo <<EOF
	,s/cat/dog/
	w
	q
	EOF

leave 'foo' looking like

	dog
	dog
	elephant

So the problem lies elsewhere. Sorry for misleading you ... I should not
have answered so quickly, but your problem seemed to fit a pattern
wherer the 'cat' solution normally goes. Next time I will read more
carefully.

Malcolm

-- 
If it walks out of your refrigerator, LET IT GO!!



More information about the Techtalk mailing list