76

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?

3
  • 3
    less: greenwoodsoftware.com/less it is part of the gnuwin32 set of ports for windows: gnuwin32.sourceforge.net/packages.html
    – MaQleod
    Commented May 19, 2012 at 2:41
  • what is wrong with the "more" command that has been a part of the command interpreter for as long as I can remember? I am guessing DOS 5.x and Winnt 3.x AT LEAST and newer. Did you even TRY to use the more command as you would in linux?? IT WORKS. Commented Mar 3, 2021 at 18:06
  • If you have downloaded git, git bash provides the 'less' , 'tail' etc. Commented Jun 19 at 14:03

8 Answers 8

82

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

5
  • 3
    Yea, 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
    Commented May 19, 2012 at 2:35
  • 4
    @Tom: That is what more does on *nix as well. less is the one with backwards scrolling support, as you've noticed. Commented May 20, 2012 at 21:31
  • 4
    Get less. less is more.
    – hookenz
    Commented Mar 4, 2019 at 20:21
  • 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
    Commented Mar 12, 2019 at 12:25
  • That command output should be fenced text; not a screenshot. Commented Jul 17 at 23:23
9

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.

1
  • This is the most up-to-date answer here! Commented Oct 15, 2020 at 2:37
7

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.

1
  • 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
    – user189814
    Commented May 27, 2016 at 11:01
4

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

2
2

I install a ready-to-run less via choco:

choco install less

https://chocolatey.org/packages/Less

It uses the binary generated by the aforementioned less-Windows

1
  • winget install jftuga.less
    – alexei
    Commented Apr 22, 2023 at 8:29
1

Here you can find up-to-date less builds for Windows: https://github.com/jftuga/less-Windows/releases

This are the reccomended Windows builds on the less official download page.

1

If you're running a recent version of Windows and have Windows Subsystem for Linux (WSL) installed, you can run Linux's less directly from CMD:

wsl less "my file.txt"

File paths must be expressed in terms of the WSL filesystem:

wsl less "/mnt/c/Users/coejoder/Documents/my file.txt"

Or converted using wslpath in a subshell:

wsl less "$(wslpath "C:\Users\coejoder\Documents\my file.txt")"
0

I used UnxUtils for many years. In most recent installations, I just use the Git for Windows which embeds mingw-based utilities. It installs all same commands than UnxUtils and also includes compression utilities variants like zcat, zless.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .