[Tutor] Scrolling through output in shell

Mike Hoy webmaster at mikehoy.net
Thu Nov 20 01:43:43 CET 2008

os.system("cat textfile | less")

did the trick, thanks everyone.

On Wed, Nov 19, 2008 at 2:34 PM, Lie Ryan <lie.1296 at gmail.com> wrote:
> On Mon, 17 Nov 2008 09:20:55 -0500, Shawn Milochik wrote:
>> On Sun, Nov 16, 2008 at 1:21 PM, Mike Hoy <mhoy06 at gmail.com> wrote:
>>> I'm writing a small program that writes to a text file. I want to be
>>> able to view the contents of the text file inside of shell. But the
>>> file is too large for a small shell window. Is there a way for the user
>>> to 'scroll' through the contents of file that has been read into the
>>> program? I noticed that on the man pages that you can do that although
>>> I'm sure it's not written in python. Do I need to find a new language
>>> to write this in? Maybe use a different language for the output and
>>> still use python? Any help appreciated.
>>> --
>>> Mike Hoy
>>> http://www.mikehoy.net
>> As Alan has noted, your request isn't perfectly clear. So, I'm going to
>> change your question and answer it. If I picked the wrong question,
>> please be more explicit in your next reply.
>> Question: How can I read a text file from the command line if the file
>> is too large to fit on the screen at once?
>> Answer: more or less
>> If you're in Windows, you can use the more command: more file.txt That
>> will allow you to scroll up and down.
>> If you're on pretty much any other OS, you can use more or less. I
>> prefer less, because it has more features. You use it the same way you
>> use more:  less file.txt
> If that explanations mixing up "more" and "less" as names of programs and
> more and less for real more and less doesn't confuse you, I think you
> must already know what "more" and "less" is.
> "more" and "less" is a pager program, used to provide scroll facility to
> a file or a stream. Windows only have "more", many Unix-like OS provide
> both "more" and "less". The most striking difference between "more" and
> "less" is that "more" is simple forward-only, you can't scroll up, only
> down. "less" support both backward and forward navigation.
> As the manpage of "less" explains: 'less - opposite of more'
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Mike Hoy

More information about the Tutor mailing list