less is a terminal pager program used to view (but not change) the contents of a text file one screen at a time.

learn more… | top users | synonyms

54
votes
3answers
14k views

Can less retain colored output?

Can I get less not to monochrome its output? E.g., the output from git diff is colored, but git diff | less is not.
31
votes
7answers
25k views

Is there a way to dynamically refresh the less command?

I like the watch command, but it has its limitations. I'm curious to know whether I could mimic the functionality of watch with less. I'm mainly looking for the ability to scroll through my directory ...
31
votes
1answer
2k views

Is there any way to exit “less” without clearing the screen?

Relatively often, I find myself wanting to quit less but leave what I was viewing on the screen, to refer back to. Is there any way to do this? Workarounds? (My current workaround is to quit, then ...
25
votes
15answers
4k views

Is there ever a reason to use `cat` when you've got `less`?

I used to use cat to view files. Then I learned that less is usually better, and is a must if the file is longer than a few dozen rows. My question: Is there ever a reason to use cat instead of less? ...
23
votes
3answers
4k views

Colors in Man Pages

When I look at a man page in my 'console' (not an xterm) I see some coloration, but I don't get this in my xterm's (e.g. konsole) is there any way I can enable this? hopefully a fairly simple ...
18
votes
1answer
3k views

The 'less' command-line equivalent of 'tail -f'

I would like to open up a file using less, and have it automatically scroll the file similar to tail -f. I know that I can do less file, and then hit Shift-F to forward forever; like tail -f. I need ...
17
votes
4answers
2k views

How can I use man without less?

By default, man uses less to output text. How can I tell it to just output to stdout? My terminal emulator has a scroll bar and search function and I want to use those instead of the arrow keys.
17
votes
6answers
2k views

Is there a way to make tail -F beep?

Is there a way to make tail -F or less beep (ring the bell in a terminal) when new data comes in (a new line is added to the file). Or is there any other unix utility to do this on a linux or mac.
17
votes
1answer
5k views

What are the differences between most, more and less?

I'm now using Arch Linux, and find a command most works like more and less. To understand the differences between them is a confusing problem. This Question has mentioned the differences between less ...
16
votes
7answers
4k views

Isn't less just more?

When I do more filename and less filename, it would seem that the resulting terminals are quite similar. I can navigate and search through my files identically (j, Space, /pattern, etc.). I find it ...
14
votes
2answers
308 views

set tab width for less output

Is it possible for less output to set the tab width to a number X as it is for cat?
12
votes
2answers
1k views

How to use `cat` or `less` depending on the line count?

When looking at the content of files, I'd like to automatically cat short files but less those that exceed the screen size. I could use something with wc -l, but is there a better way that maybe also ...
10
votes
2answers
2k views

Can less invoke vim instead of the default vi when I hit the 'v' key?

I want to launch vim instead of the default vi editor when I hit v in less. Are there any settings I can modify to allow me to do this?
9
votes
2answers
3k views

How can I view gzipped files in less without having to type zless?

I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?
9
votes
1answer
959 views

How to have tail -f show colored output with vim?

In this question, Gilles answered Yet another possibility is to run tail -f in an Emacs shell buffer and use Emacs's syntax coloring abilities. Because I'm a vim user, I'd like to do this with ...
8
votes
3answers
2k views

Force less to display a file as text

Sometimes less wrongly recognize file as binary and tries to show hexdump on LHS (usually ones with non-alphanumeric characters but still containing printable ASCII characters). How to force it to ...
8
votes
1answer
379 views

Documentation on LESS_TERMCAP_* variables?

I see these pretty colors in manpages viewed with less when setting a bunch of these variables. What do they mean, where is the documentation? Is this interpreted by less or termcap? screenshot
8
votes
0answers
271 views

scroll through output using `less` or `tail -f` while keeping the header visible [duplicate]

I am trying to scroll through some data formatted thus- NFI T[PSEC] T[K] EKIN(PSI) E(RHO) ECONS ANNEE ANNER !> 1 0.00012 0 0.45873 16.26904 16.72777 ...
7
votes
3answers
365 views

How does less know the terminal resolution?

Everytime someone set a different size for a virtual console, less recognize window-resolution (I'm assuming that ...); according to that it changes how many lines of text it should visualize. How ...
7
votes
2answers
234 views

How to set up hjkl for less?

less already uses j/k for vertical scrolling, but not h/l for horizontal scrolling (in --ch mode). The l key isn't bound to anything anyway, and h is just a synonym for H, so I wouldn't overwrite any ...
7
votes
1answer
1k views

Get colors in less command with ccze: Shift + g doesn't go to the end of file?

In all the tools to get colors with less command: -R, Pygments, GNU Source-highlight, vless, ... ccze make me sastified with below command: ccze -A < /path/to/log/file | less -R but Shift+g ...
7
votes
3answers
97 views

Can I force `man` to do lower case sensitive matching?

When I search man pages, the search is case sensitive, but only with regard to upper case letters. E.g., x will match x and X whereas X only matches x. This is the man-db version of man, used on ...
6
votes
2answers
190 views

How can I pipe colored tree result to less or more?

I get colored tree using tree -C but when I pipe it to less I get results like this: tree public/ -C | less How can I have colors in less in this case?
6
votes
4answers
493 views

pager program like less, able to repeat top N lines

Is there any way to make less program repeat first line (or first 2 lines) on every displayed page? Is there any other pager program which can do this? This would be a killer-app for database table ...
6
votes
3answers
2k views

Follow a pipe using less?

Can less follow (by pressing F) a piped input (similarly to a file)? For a file that is being written to, the command less <file> will follow the file when pressing F. But if I have a ...
6
votes
2answers
190 views

less '+>' /path/to/file

So Gilles mentioned in the chat room that: less '+>' /path/to/file can be used with less in order to view a file in reverse. I've never seen it before. I'm curious - what's going on with the ...
5
votes
4answers
386 views

How do I prevent less from clearing the screen on exit? [duplicate]

I often pipe commands to less in order to read through the output (e.g. compiler errors). MyCommand | less This is great because it makes trawling through large amounts of output easy, but when I ...
5
votes
3answers
260 views

How to scroll large datafile while keeping header

Suppose I have some large datafile, which overflow the screen in both vertical and horizontal direction. How can I browse this file, while the header-lines stay on the screen? For the moment, I am ...
5
votes
2answers
2k views

Colored man pages not working on gentoo

I have a problem using these methods to get colors in my man pages in gentoo. I've asked already in the gentoo forums but it still doesn't work, and the comments in a bug report (Bug 184604) don't ...
5
votes
2answers
216 views

Write lines to a file from less

While in vim I can write a range of lines from the file I'm viewing to another file. For example, :1,10 w outfile.txt will write lines 1 through 10 to outfile.txt. Can I do the same while I'm ...
5
votes
2answers
105 views

How do I preserve coloured output when piping to `less -R`?

$ ffmpeg -v debug ... Coloured output. $ ffmpeg -v debug ... |& less -R Dull output. How do I make the output coloured while piping it to something?
5
votes
1answer
323 views

Making less print to stdout if an entire file can be displayed on one screen

When more is passed a file whose contents can be displayed on one screen, it just writes the file's contents to stdout without pagination. If the file cannot fit on one screen, more paginates it. ...
5
votes
2answers
193 views

How do I less a filename rather than an inode number?

I have a piece of software that rotates its log files when it restarts. However, during development, I am restarting it a lot, so I would like to monitor the latest log file at any time. If I start ...
5
votes
2answers
191 views

Can I get vim-stlye (hjkl) navigation for GNU info?

The layout of my netbook's keyboard means that using the arrow keys for navigation is slightly uncomfortable. Is there a way to make GNU Info pages use vim-style hjkl navigation? I know I can info ...
5
votes
2answers
343 views

show colors and disable line wrap

Using the less paginator, you can use the -r option to properly display colored input and the -S option to disable line wrap. However, when using less -rS or equivalently less -r -S, colors are ...
5
votes
2answers
530 views

Unhighlight Last Search in 'less'

When you use a / forward search or a ? backward search in less, all instances of the file get highlighted. After I've found the instance of the word I'm looking for, what is the most correct way to ...
5
votes
2answers
83 views

“command | less” vs “less <(command)”

A common "idiom" for viewing large amounts of command output is to pipe it to less, via command | less. However, it's also possible (perhaps only in bash, haven't tested in other shells) to use the ...
4
votes
6answers
408 views

Command to output file content to stdout?

I know cat can do this, but its main purpose is to concatenate rather than just displaying the content. I also know about less and more, but I'm looking for something simple (not a pager) that just ...
4
votes
2answers
175 views

Why do 'man' pages have many extra lines?

When I run the command: man fork There is a highlight line at the bottom that reads: Manual page fork(2) line 52/99 (END) But when I navigate to line 53 and up to 99, these are just blank ...
4
votes
3answers
3k views

Characters encodings supported by more, cat and less

I have a text file encoded as following according to file: ISO-8859 text, with CRLF line terminators This file contains French's text with accents. My shell is able to display accent and emacs ...
4
votes
1answer
240 views

How can I get less or cat to use color in the output from .cat of my .bashrc, similar to vi 'ing it?

When I vi my .bashrc file it is colorized, i.e. but when I cat or less the file I get all white, i.e. How can I get cat (and less) to have color? cat does have color for my ruby .rb files but ...
4
votes
2answers
43 views

Can less load lines which were appended to a file after opening?

When I am viewing a log file in less is it possible to make less reload the file to get lines which were appended to that file since it was opened?
4
votes
3answers
629 views

Piping into less and editing: “cannot edit standard input” error. Workarounds?

I recently learned that if I page my files with less, I can press v and open the buffer in Emacs. This works as long as I have the environment variable $EDITOR set up correctly, which in my case I ...
4
votes
1answer
1k views

Instant search in less command? (Similar to incsearch in VIM)

Is there a way to search, while I'm typing in less? Just like the vim option, set incsearch. As I didn't find a proper way to do it, is there any similar tool that can do it?
4
votes
2answers
127 views

Shift-Space in less

In modern web browsers and other software with text content, Space scrolls down more or less a screenful. ShiftSpace scrolls up in everything but less. How can one use ShiftSpace to scroll up in ...
4
votes
1answer
24 views

How to export a subset of a 'less' output [duplicate]

Every so often I need to take a subset of a log file and save it into a file for later use. I use less a lot to view and search within the logs and for exporting the interesting part, I currently do ...
3
votes
2answers
637 views

Get 'less' to display filename

Something that seemed quite useful to me when looking for a certain var in a bunch of config files: less * | grep some_var So this returns the value of some_var without manually looking through all ...
3
votes
2answers
680 views

How to change default “reading” program?

right now when I run man smth or similar less is used to view it. However, on Mac OS X, I really like scrolling with touchpad instead on up/down or page-up/page-down buttons. Is there a way to just ...
3
votes
1answer
183 views

Using more command

Is there any case or reason to use "more" unix command instead of "less". As far as I see "less" is "better" in all senses, so does it mean that "more" is a command which has no reason to be used when ...
3
votes
3answers
59 views

Why can't ed be exited with C-c?

The program ed, a minimal text editor, cannot be exited by sending it an interrupt through using Ctrl-C, instead printing the error message "?" to the console. Why doesn't ed just exit when it ...