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

5
votes
3answers
340 views

How do I write all lines from less to a file?

I've piped a command to less, and now I want to save the command's output to a file. How do I do that? In this case, I don't want to use tee, I want a solution directly from less, so that I don't ...
2
votes
1answer
19 views

`diff -y file-{a,b} | less` and DOS line endings display issues

In my current job I often have to work with files from Windows machines which most of the time isn't a big deal, but when piping a side-by-side diff to less, not only are the ^M being displayed, but ...
2
votes
2answers
31 views

Man page highlight color

To colorize my man pages, I put this code from archlinux.org into .bashrc: man() { env LESS_TERMCAP_mb=$'\E[01;31m' \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ LESS_TERMCAP_me=$'\E[0m' \ ...
4
votes
3answers
34 views

Horizontal scrolling in smaller increments with less -S

I'm using less to parse HTTP access logs. I want to view everything neatly on single lines, so I'm using -S. The problem I have is that the first third of my terminal window is taken up with metadata ...
1
vote
0answers
12 views

Can 'less -F' be usefully combined with termcap initialization?

less -F closes less if the contents fit on one screen. However, if I use termcap initialization, i.e., I don't use -X and the file fits on the screen, nothing is printed because less displays the ...
1
vote
2answers
76 views

How does Bash pipe large amounts of data?

Let's say you want to cat the contents of a really big file, but want to view it a few bits at a time. Let's say one were to do the following: $ cat /dev/sda1 | less As a programmer of languages ...
3
votes
1answer
40 views

Can I add mouse support in less?

I've just discovered that I can add the following lines to ~/.vimrc. set mouse=a :vmap <C-C> "+y This has the effect of being able to select text with the mouse (i.e. in visual mode), and ...
3
votes
1answer
28 views

How to set `less` jump point to center of terminal rather than top

If one searches in less by typing /search term and jumping to search results with n and N the view of the text jumps so that the occurance of the search term is at top of the terminal. Displaying the ...
1
vote
1answer
72 views

Neither `less` or `less -X` clear screen on exit

Neither less or less -X clear screen on exit. At the same time, vim does.... Env iTerm2, protocol mosh, server Centos + tmux + zsh iTerm2: report term as xterm-256color tmux: set -g ...
0
votes
2answers
40 views

Are `less textfile | col` and `cat textfile` the same?

Do less textfile | col and cat textfile accomplish the same thing? I wonder if man mysql | col -b > textfile and man mysql > textfile do the same?
1
vote
1answer
66 views

Use case for /usr/bin/lessecho

I can not come up with an example of how I could/would use lessecho. The description in the man page is fairly straight forward but is not helping me come up with a use case: DESCRIPTION ...
2
votes
1answer
373 views

Which file defines the LESSOPEN environment variable?

please advise me about the following. On my Linux machine - I do the following: $ env | grep -i LESSOPEN LESSOPEN=|/usr/bin/lesspipe.sh %s So from env command I see that: ...
4
votes
1answer
42 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 ...
2
votes
1answer
28 views

Hide lines based on multiple patterns

I'm using less to view log files quite a lot and every so often I'd like to filter the output by hiding lines which contains some keywords. In less it's possible to filter-out lines with ...
5
votes
6answers
943 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 ...
2
votes
2answers
40 views

Live replacement, while viewing log using LESS

It's very convenient to monitor logs using less command - you see what is going with your system as it happening. The bad thing is that my logs are optimized for grep tool: each atomic action is ...
1
vote
1answer
40 views

How to make `less -FX' play nice with a 2-line shell prompt

My shell prompt is two lines long (a fancier version of [%n@%m %~]'$'\n''%#. I have $LESS set to -FX. When I quit less, it leaves a single line at the end of my screen, and since my prompt has two ...
1
vote
0answers
27 views

man causes a broken pipe when using a pager other than less

I'm trying to write a simple script to format my man pages, but I've run into a broken pipe error. These lines both cause the error: env MANPAGER=cat man $foo man -P cat $foo and this is the ...
5
votes
2answers
153 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?
3
votes
3answers
111 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 ...
2
votes
1answer
12 views

When using less with -S option, it moves text on top when I press right key

I am using less as pager in MySQL, and I have configured it with -S flag, so that it does not wrap text. The only issue is that, when I have a small result set and want to see what is on the right, I ...
5
votes
4answers
428 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 ...
1
vote
1answer
71 views

Less command change color of “~” and “(END)”?

How do I change the color of the "~" characters that go along the edge of a Less command output. And how to change the color "(END)" at the bottom?
3
votes
1answer
44 views

Can I make “less” execute arbitrary commands with a single key sequence?

The crux of my question is stated in the title. Reading the less and lesskeys manpages, I have created a file containing: ^B shell touch ~/testfile and run it through lesskey to generate ...
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 ...
14
votes
2answers
487 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?
1
vote
1answer
184 views

Piping the output of ls or tree to less loses colors? [duplicate]

tree and ls can distinct file types by coloring filenames differently. tree and ls often output a long list of files (including directories), so I pipe the stdout output to less. But less doesn't ...
5
votes
2answers
122 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 ...
2
votes
0answers
47 views

A terminal that is always scrollable or forever like less?

I'm currently using #!Waldorf, but have used Manjaro, Mint, Ubunto, Fedora, etc. Is there a way to make my terminal always behave like it's passed to less but without the (END) "feature" that ...
1
vote
2answers
37 views

How do you make less show the filename?

I often have multiple terminal windows opened with less (eg comparing various log files). I forget which file is which. Is there a similar command to ^G in vi which displays the name of the file ...
2
votes
1answer
48 views

Exiting a '&pattern' search in less

After using a search in less of the format &pattern, which displays only matching lines, how can I go back to displaying all lines in the file? Esc doesn't do anything as far as I can tell. ^C ...
4
votes
2answers
617 views

Negative lookbehind/ahead assertions in Linux less pager (or vim)

I want to find all instances of "index" not followed by .php in a log using less. /index(?!\.php) does not work. Is this possible? What is the regex for less and vim (do they differ?). Is this not ...
7
votes
3answers
119 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 ...
0
votes
0answers
41 views

Why does SPACE sometimes not work with more (or less)

Usually with |more I press space to get another screenful. But with some commands space just does nothing, and I need to actually keep doing SPACE-ENTER to scroll forward a screen at a time. Both more ...
6
votes
2answers
216 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 ...
4
votes
1answer
294 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 ...
6
votes
1answer
530 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 ...
3
votes
1answer
918 views

less is always case-insensitive

Trying to find out how to use case-insensitive searches in less I found this on serverfault. That seems to perfectly answer my question. The problem is: It doesn't work like that here (openSUSE 13.1; ...
0
votes
1answer
52 views

Piped search queries in vim or less

I would like to be able to search a log file for lines that being with ^2014-02-18 15:30:[0-9:,]* and have UserName:someguy much later in the same line. I am sure I could do a regex to include any ...
6
votes
2answers
325 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 ...
1
vote
1answer
212 views

Cat and Less give different output

I executed the following command # top > /home/user/top_output.txt Nothing Happened for a while and then i pressed Ctrl+C. When i checked the file that was created, it had the contents in it. So ...
3
votes
1answer
29 views

Have man pages display how far I am through the file

With less, the -m flag extends the prompt to include a percentage. But how do I get man to do the same thing?
2
votes
1answer
91 views

less command runs out of memory

When searching for string (no regex etc.) in large file less filename and less -b 1 filename quits or prints it cannot allocate memory. top shows less using roughly about 5% of memory before it dies ...
3
votes
1answer
81 views

Customizing less colors

When using less in OS X, how can I customize the colors with with things are displayed? When I run less within an ansi-term in Emacs the colors don't come out nicely. $ less --version less 418 ...
4
votes
2answers
53 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?
2
votes
4answers
856 views

How to copy multi-page text from the terminal into the clipboard?

I was viewing a man page for a software on my machine and I needed to copy-paste some of that text but the text was much more than one page. I'm aware I can direct the output to a file and use UI ...
8
votes
1answer
552 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
2
votes
2answers
95 views

can I get the shell to decide ls or less depending on filetype?

Very often I find myself looking through directories using 'ls', then when I find the file I want, I use 'less' to look at the file. So for example to find a mysql log file I might type ls /var ...
3
votes
1answer
195 views

less --quit-if-one-screen without --no-init

I'm on a terminal that supports the alternate screen which is used by less, vim, etc. to restore the previous display after exiting. That's a nice feature, but it really breaks the ...
-2
votes
3answers
94 views

How to get an specific amount of lines in the console with less? [closed]

Can I get the specified number lines at a time by using the less command? I want just ex. show 20 lines even if my screen allows more.