Less or More in Windows?

51

15

Is there a command in the Windows DOS prompt that is equivalent to the UNIX less or more?

Basically, the problem is that when I type hg log, the output has too many lines to fit on the screen and I want to paginate it.

Any ideas on how to solve this problem?

Jeffrey Greenham

Posted 2012-05-18T23:50:35.173

Reputation: 611

2

less: http://www.greenwoodsoftware.com/less/ it is part of the gnuwin32 set of ports for windows: http://gnuwin32.sourceforge.net/packages.html

– MaQleod – 2012-05-19T02:41:48.610

Answers

59

Windows has the command more. E.g. (Taken from Wikipedia)

To display the file named letter.txt on the screen, the user can type either of the following two commands:

 more < letter.txt
 type letter.txt | more 

So in your case you want hg log | more.

For heavier usage you will want something like UnxUtils or GnuWin32, which have a more powerful less utility.

. enter image description here

Renan

Posted 2012-05-18T23:50:35.173

Reputation: 7 463

2Get less. less is more. – Matt H – 2019-03-04T20:21:43.927

unfortunately, hg diff | less and hg diff | more don't preserve color highlighting, so unlike with git, with hg one either has colorful text or scrolling... (tested on Win 10 x64, with less from UnxUtils, in cmd) – YakovL – 2019-03-12T12:25:18.670

3Yea, but the Windoze version only pauses the screen for a page at a time. You can't page up and down through the output. I've never used gow (mentioned in another reply) but I use UnxUtils every day. I love having grep, more, head, tail, sed, wc and other tools in Windoze. – Tom – 2012-05-19T02:35:04.527

4@Tom: That is what more does on *nix as well. less is the one with backwards scrolling support, as you've noticed. – Daniel Andersson – 2012-05-20T21:31:52.280

4

If you don't mind installing additional software gow is a nice toolkit with a set of standalone unix style tools that you can use, including less and more - it requires an install since it adds itself to path, but you can copy and use the install directory elsewhere as well.

Journeyman Geek

Posted 2012-05-18T23:50:35.173

Reputation: 119 122

This toolkit is epic! less, grep, wget, curl, ssh, whereis.. and many more standard unix console tools, directly in windows CMD! and only 18MB.. windows CMD is now actually useful – Michelrandahl – 2016-05-27T11:01:36.783

4

Up-to-date less build for Windows is here: http://adoxa.altervista.org/less/index.html

johndoe

Posted 2012-05-18T23:50:35.173

Reputation: 126

Thanks. less is a very important tool. Other implementation I have used suffer from the MSVCRT console I/O bug: https://yongweiwu.wordpress.com/2016/05/27/msvcrt-dll-console-io-bug/. This one is working well.

– Yongwei Wu – 2017-06-22T13:05:29.217

Thank God for that utils to be ported on windows, I feel much better now! :) – fduff – 2018-07-24T11:00:19.237

3

On Windows 10, you can install the Windows Subsystem for Linux:

The Windows Subsystem for Linux lets developers run Linux environments -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.

Once installed, start bash.exe and run less /mnt/c/temp/test.txt to open the file test.txt located in c:\temp.

Mathias

Posted 2012-05-18T23:50:35.173

Reputation: 59