I want to learn to use the shell and was wondering why this didn't do as expected

Kevin Buettner plug-discuss@lists.plug.phoenix.az.us
Thu, 20 Feb 2003 13:32:54 -0700


On Feb 20,  1:25pm, Michael Havens wrote:

> Why did my version (sort mypasswd >mypasswd |cat mypasswd) erase it?

Because the redirection operator opens and truncates the file.  This
is done by the shell before the sort program even gets a chance to do
its own open() of the file.

Kevin