🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Thomas Kwong Thu, 27 Dec 1990 00:31
Redirection
#359
Author: Thomas Kwong
Date: Thu, 27 Dec 1990 00:31
25 lines
884 bytes
In the final exam ( Unix and C ) that I just take, one UNIX
problem is like this:

%cat myfile
word1 word2 word3
word4 word5
word6
%wc myfile
     3     6    36   myfile

%wc myfile > myfile
%cat myfile
     0     0     0   myfile

How come MYFILE becomes that?

I think it should be like:
     3     6    36   myfile
because output of wc myfile is redirected to myfile.

Can anybody tell me why?

Thomas Kwong.

------------------------------ 6600tom@ucsbuxa.ucsb.edu
Re: Redirection
#362
Author: Steven Freed CIRT
Date: Thu, 27 Dec 1990 16:44
19 lines
905 bytes
>%wc myfile
>     3     6    36   myfile
>
>%wc myfile > myfile
>%cat myfile
>     0     0     0   myfile
>
>How come MYFILE becomes that?

because the original "myfile" gets overwritten by the new "myfile"
(from the redirection) by the shell BEFORE wc is run, therefore,
the only thing wc sees is an empty file.



--

Thanks,
Steve.                    sfreed@ariel.unm.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads