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

1
vote
1answer
26 views

How to run a long running grep, pipe the result into less and put everything into background?

I often find myself in the situation where I need to find a code base for a given symbol like so: find src/galio -not -path './src/stapi-sdk/apilib/* -regextype posix-extended -iregex ...
-1
votes
0answers
17 views

Why is the infobar of the man pages displaying the line number as x/y wherein x < y when it reaches 100 %?

I just installed the program ii and opened its manual entry by typing man ii in the shell. As I scrolled down towards the end the percentage neared twoards 100 while the line number increased, yet the ...
0
votes
0answers
27 views

Make /less/ not exit on G command [on hold]

I am currently migrating an application from Solaris to Linux. Most of the time I am happy with the change, but using the less command became a real pain. I have managed to make less keep an output ...
2
votes
1answer
23 views

How to chain multiple LESSOPEN scripts?

Linux distributions nowadays have a default LESSOPEN set to /usr/bin/lesspipe which allows one to easily inspect e.g. zipped files or PDF files. Now I wanted to see whether I can add syntax ...
3
votes
2answers
43 views

less: /pattern search starts at first line

Consider the following file: $ LESS= \less test abc def abc By default, searching /abc in less will jump to line 3 since /pattern search starts at second line according to man 1 less: /pattern ...
1
vote
3answers
33 views

xargs git: skip user input

I have an xargs function that calls git commands recursively. When I now call gitr log I have to hit enter until the end or q to get the next xargs call to run. Can I tell xargs to skip user input ...
0
votes
1answer
30 views

how to stop at a specific point in a list

I created a shell script called blossom() because my girlfriend's dog Blossom poops and pees on the floor all the time. blossom() { echo poops and pees on floor all the time } Because I am such ...
1
vote
1answer
30 views

Can less be instructed to collapse blocks of lines

Is there a way to instruct less to fold blocks of lines matching some criteria into a single line in the view? For example while viewing a mail spool with less, the mail headers may take up a lot of ...
12
votes
3answers
454 views

No colored output in less for the ls command

If I run ls I get colored output which I find pretty handy for quickly getting a glance of the kind of file. When I try to pipe it to less even with the -r and -R flags the coloring always get lost. I ...
4
votes
4answers
79 views

Viewing man pages with scroll wheel support

I'd like to use the scroll wheel (xterm mouse escape codes) to scroll through man pages, like I can in emacs with xterm-mouse-mode. less doesn't seem to have support for that and short of recompiling ...
2
votes
2answers
67 views

Exit from less by pressing ESC key

Can I setup less program to exit from it by pressing ESC key?
0
votes
2answers
41 views

Find out which encoding method less uses to display the content of a text file?

There is a plain text file, which Emacs can't display correctly, but less can. I wonder if less automatically detects the encoding method for each individual text file, or just use a single default ...
12
votes
1answer
767 views

grep inside less?

I'm currently sifting through a lot of unfamiliar logs looking for some issues. The first file I look at is Events.log, and I get at least three pages in less which appear to display the same event ...
1
vote
1answer
63 views

Make Less highlight search patterns instead of italicizing them

To my understanding man uses less as a pager, and when searching for keywords using less it "highlights" keywords with italics. I find that really inconvenient, so I'd like to change this to something ...
2
votes
2answers
53 views

What hotkeys are supported when reading a man page?

People usually know after running man fdisk that they can search with: /foo (where foo is the string to be searched for). They can also use Up/Down and PgUp/PgDown to scroll up and down. What ...
3
votes
1answer
90 views

How do I view cp1251 text file in UTF-8 console?

Attempt 1: $ less subs.srt "subs.srt" may be a binary file. See it anyway? <C8><F2><E0><EB><FC><FF><ED> ... Attempt 2: $ LANG=ru_RU.CP1251 less subs.srt ...
1
vote
2answers
80 views

Stdin Input Behavior Between “cat” and “less”

When I issue cat, the terminal hangs waiting for stdin input. However, when less is issued, I get Missing filename ("less --help" for help). It is known that both less and cat accepts stdin input. ...
1
vote
0answers
25 views

Delete lines from a file which opened in less mode

I have a file (huge size) which cannot be opened in vi but in less mode and I want to delete the lines which I do not required. But I am unable to delete lines from file open in less mode. Please ...
6
votes
3answers
400 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
26 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
93 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' \ ...
5
votes
4answers
90 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 ...
4
votes
1answer
37 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
125 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
152 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
33 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
142 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
44 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
88 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 ...
3
votes
1answer
605 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
51 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
50 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
2k 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
56 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
51 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
40 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
192 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
239 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
14 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 ...
6
votes
4answers
453 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
123 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
65 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
272 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 ...
15
votes
2answers
749 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
389 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
137 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 ...
1
vote
1answer
58 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
43 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
65 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 ...
5
votes
2answers
979 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 ...