I want to learn to use the shell and was wondering why this …

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Kevin Buettner
Date:  
Subject: I want to learn to use the shell and was wondering why this didn't do as expected
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