Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.unix.wizards Subject: Re: Why is 'more' giving the 'next file' prompt? Message-ID: <36072@think.Think.COM> Date: 3 May 90 22:29:54 GMT References: <1990May3.160744.25250@bath.ac.uk> Sender: news@Think.COM Reply-To: barmar@nugodot.think.com (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 44 In article <1990May3.160744.25250@bath.ac.uk> exspes@bath.ac.uk (P E Smee) writes: >Ok, folks, here's one which my boss asked for an answer to the other >day, and I don't see the answer. The context is (4 different variants >of) 4.3BSD (on 4 different platforms). Make yourself a small text >file, say 'fred'. Then try the command line: > > cat fred | csh -c 'cat >tempxxx ; more tempxxx' > >Before 'more' puts anything out, it gives the 'Next file (tempxxx):' >prompt. Why does it think tempxxx is the second file? What's the >first? 'more' is noticing that its standard input isn't a terminal, so it's first displaying the standard input. Here's a way to see this more clearly: create two text files, 'foo' and 'bar', and then do: more foo < bar First it will show you the contents of 'bar', and the second file will be 'foo'. You can fix your problem by making 'more's standard input a terminal, e.g. cat fred | ( cat >tempxxx ; more tempxxx The purpose of >piping through 'cat' into a temp file and then giving that to 'more' as >an arg is that in that case 'more' will allow you to move backwards; >while if 'more' is processing stdin you can only go frontwards. Get 'less'. It allows going backward in any stream. > In the >context of the original, the shell invocation is needed in order to >allow the (second) 'cat' and the 'more' to be joined with ';' rather >than being '|'ed together. You can also use parentheses, as in my example. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar