Questions tagged [less]
less is a terminal pager program used to view (but not change) the contents of a text file one screen at a time.
403
questions
4
votes
1
answer
86
views
Inside less, is there an equivalent of ctrl-Z to recover the pager prompt?
I will occasionally use the pickaxe functionality of git to locate changes of interest. This can be quite slow, obviously (the same would apply to, say, hg grep), but more significantly it is bursty: ...
3
votes
0
answers
57
views
Searching for literal strings like '***' using less
In trying to search for the literal string ***, less puts up a couple roadblocks. The asterisk has a special meaning when used as the first character of the search pattern (ignore EOF). No problem, ...
2
votes
1
answer
53
views
Scroll to the end in less without stretching out single-page input
When I pipe something into less --quit-if-one-screen +G (alias -F +G), less opens and scrolls to the end if the output exceeds the terminal size.
Unfortunately, it also scrolls to the end before ...
0
votes
0
answers
10
views
Less in custom distro ignores all keyboard input
In the custom distro I'm running on an embedded system the tool 'less' is broken. It ignores all keyboard input and just echoes it to the screen. To quit I have to use ctrl-z and kill %1.
I've used ...
0
votes
2
answers
101
views
In less: how to enter as search pattern '(#'
Im less, version 590, I can enter as search pattern \( to search for an open parenthesis.
And I can enter # (hash character) to search for this.
But when I have to search for both two characters, open ...
-1
votes
1
answer
31
views
less option --save-marks does nothing
I less vesion
less 590 (GNU regular expressions)
I use
export LESSFILE="/root/.lesshst_for_manpages"; export MANPAGER="pager --save-marks -I"; man -L en <<somemanpage>>;...
0
votes
0
answers
11
views
For less: how to specify key-sequences that less does not understand?
When typing in a search pattern, there are three key sequences for which less does not make the proper action but instead prints (as input) the ESC code of the key.
These are:
ESC[2n insert
ESC[...
1
vote
0
answers
52
views
Why bash for loop goes to stopped job when Ctrl+C is pressed?
Suppose I have a log file generated this way:
yes | head -n 1000000 > log
Now when I view it like this
for i in log; do cat $i; done | less -S
press Ctrl+C in less and quit it with q, some ...
15
votes
2
answers
863
views
How can I disable `v` keybinding in less?
When I use less and press v it switches into the currently set editor (Emacs or vim).
MISCELLANEOUS COMMANDS
v Edit the current file with $VISUAL or $EDITOR.
Is it possible to prevent this ...
0
votes
1
answer
53
views
Search in whole .bash_history list with full-featured regex engine
When I have to search backwards in the .bash_history list I want to see the timestamps as were created by HISTTIMEFORMAT. And the results have to end up in a pager, where regex can be used for ...
1
vote
0
answers
15
views
less: do not display "filename (END)" at the end of page [duplicate]
I need less to display a file without any additional formatting characters.
I found the --tilde option, which got rid of the ~ characters.
Now I only need to get rid of the:
(END)
or
<filename> ...
2
votes
0
answers
47
views
custom keybindings for less (lesskey)
the manpage says I can use $HOME/.lesskey file to define my own custom keybindings for less. It even shows some examples, such as
...
n repeat-search
\en repeat-search-all
...
q ...
1
vote
1
answer
170
views
simplest possible pager
In mc (midnight commander), I can define custom command for viewing files, ie:
shell/i/.jpg
Open=gpicview %f
View=file %f | less
The command file %f has to be piped to a pager. I am using ...
6
votes
2
answers
848
views
What are these > at the right of unterminated lines, when I do a systemctl status or a journalctl for example?
When I do a sudo systemctl status elasticsearch.service or a journalctl -xe on èDebian 11_ I have this output:
many lines are ended with > characters and I don't know how to handle these lines to ...
16
votes
2
answers
1k
views
How can I keep colouring when piping man to less?
I have this in my .zshrc file
export MANLESS=""
export LESS="--RAW-CONTROL-CHARS"
export LESS_TERMCAP_mb=$(tput bold; tput setaf 5)
export LESS_TERMCAP_md=$(tput bold; tput setaf 1)...
1
vote
2
answers
46
views
How to terminate _follow_ mode in **less** (`+F`) from pipe?
Assuming the following dummy command in bash:
### dummy long_operation_cmd function, for easy reproduction:
function long_operation_cmd() {
echo "operation 1"
sleep 5
echo "...
0
votes
1
answer
36
views
Merge multiple files and format output into columns with line wrap
I'm trying to show multiple files to a user within less. These files have relatively long lines and contain the same text but in different languages (differences in line length to be expected).
...
0
votes
1
answer
51
views
less command: b/f vs w/s
About the less and according with:
Less command
Linux / Unix Colored Man Pages With less Command
indicates the following:
f ^F ^V SPACE * Forward one window (or N lines).
b ^B ESC-v * Backward ...
5
votes
2
answers
493
views
less command g vs p option
In less for navigation purposes according with this tutorial
Less Command in Linux
indicates:
g Go to the first line in the file.
p Go to the beginning of the file.
I tested both, and of course ...
1
vote
1
answer
119
views
How to make less +F follow symbolic link if link changes
When you tail a file that is a symbolic link you can make tail follow the link if it changes with tail -F.
Is there someone that have a solution to make less behave the same way if you're opening a ...
1
vote
1
answer
114
views
Auto page down / scrolling after a few seconds using more, less, or something similar
When using more or less, the output is paused at the end of each page.
Is there some way to have it pause only for a few seconds (configurable or not), and then continue to the next page? Is there ...
0
votes
1
answer
44
views
where in the FHS does command less store its buffers?
Using Kubuntu 20.04, which is running from an USB stick. Therefore there is a /cow overlay file system mounted on /. The USB stick has a total capacity of 32 GB, But to the cow overlay file system ...
1
vote
0
answers
109
views
How can I recursively search file contents by ANDed patterns and print the output like ag/the silver searcher would?
This will be easier to explain via example. Here are my input files:
file1:
x
x
a
b
c
x
x
file2:
x
x
c
b
a
x
x
file3:
x
x
x x a b c x x
x
x
file4:
x
x
x x c b a x x
x
x
file5:
x
x
a b
x
x
file6:
...
1
vote
1
answer
28
views
Should one report the output of valgrind to less developers?
I found that in Linux Mint, the command valgrind less outputs
still reachable: 22,499 bytes in 31 blocks
Is that a bug? Should one report this kind of issues to the developers?
0
votes
0
answers
37
views
Want less cmd to clear content on exit in server
Want less cmd to clear content on terminal on exit in server and display back what was there before. I am used to this in my mac and wants the same behavior in the server.
My internet search gives ...
2
votes
1
answer
188
views
Is `git branch` using `less` a recent change? Or is `less` behaving differently recently?
Appologies for the vague title.
I frequently execute git branch throughout the day, and it seems at some point recently (perhaps in the past month?) the behavior has changed. I recall previously git ...
2
votes
1
answer
41
views
less: custom shortcut for previous searches (up-arrow)
The less viewer allows some customization using the ~/.lesskey file, but it does not seem to have any effect in the context of searching. For example, I can map ^P to the up arrow, and this works for ...
0
votes
1
answer
29
views
less -n default behavior, is not the same as indicated through man
For a MacOS and Ubuntu Server 20, with the command man less I can read the following:
-n or --line-numbers
Suppresses line numbers. The default (to use line numbers) may cause less to ...
1
vote
1
answer
288
views
Why the LESS_TERMCAP settings does not work when put it into ~/.profile
I have the following LESS_TERMCAP settings:
# less config
export LESS=-R
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
export ...
5
votes
1
answer
408
views
Using anchor ^ pattern when using less / search command
When navigating through Linux man pages, sometimes you need to query the meaning of flags like -p or -al in the man pages.
The default text reader for man pages is less and I'm trying to use the / ...
1
vote
1
answer
177
views
Does less block the input process from writing to stdout until the user advances a page?
I have a command which streams data from a server and writes lines to stdout. There is a large number of records that I would like to pipe to less, but I would like to prevent my tool from continuing ...
0
votes
1
answer
44
views
Make `less` exit after last page or `more` interpret colors
In a script, I’m doing a git diff that I want to quickly page through. When I’m finished, the pager will exit and the script will continue.
more is great for the task, because I can space through it ...
2
votes
4
answers
494
views
Why this word can't be grep?
I have access to busybox only, v 1.27.
I'm trying to use a huge TXT file I extracted from a PDF document as a TXT dictionary, to be console friendly. The word I'm trying to get is the very first word ...
0
votes
2
answers
64
views
Search with less
In the output of wget --help I would like to quickly go to the place where the --header option is explained.
I try searching with less. man less explains:
/pattern
Search forward in ...
0
votes
1
answer
32
views
How to add empty new lines in less (log viewer)?
When I monitor some log file with tail -F file.log, I can press enter to add some space between actual log lines and the new ones, for example:
some log 1
some log 2
some log 3
some log 4
some log 5
...
2
votes
1
answer
201
views
less: how to skip N files
From the less man page:
:n Examine the next file (from the list of files given in the command line). If a number N
is specified, the N-th next file is examined.
How this number N can be ...
2
votes
1
answer
3k
views
search last occurrence of string in less
What's the best way to search for the last occurrence of a string in less?
?string works for small files but doesn't seem to work with large or non-trivial syntax-highlighted files (eg, cat /var/log/...
1
vote
1
answer
252
views
less a file with JSON rows - how to highlight/colorize the rows?
I have log files with json rows inside - less displays it as just plain text
Can I colorize the output with less abilities?
As well as I didn't find any less-compatible third party tool with json ...
2
votes
1
answer
266
views
Setting LESS_TERMCAP_* variables with $(tput ...) in ~/.profile not working
This is my ~/.bashrc:
# ...unnecessary lines skipped...
# man colors
LESS_TERMCAP_mb=$(tput blink) # start bold
LESS_TERMCAP_md=$(tput setaf 2 ; tput bold) # start bold
LESS_TERMCAP_me=$(tput sgr0) # ...
1
vote
1
answer
111
views
lesskey: add alt+right keybinding to less
I used cat -vte to see what escape codes my terminal emulator sends when I press alt+right:
❯ cat -vte
^[[1;3C
Then I added this escape code to my lesskey file ~/.less:
\e[1;3C forw-scroll
Finally ...
0
votes
1
answer
106
views
Mac Terminal Git + Less doesn't show the first line of output
I have problems with git and less commands output in the standard Mac Terminal app.
For some reason, when I do git log or something else requiring less, it always skips the first line of output. There ...
0
votes
2
answers
167
views
Page break characters for more/less
I am on Mac OS. I have a C++ program that generates 1000+ lines of data that I redirect to a file. I then use less / more to go through the file. I'd like to have less pause at user-defined chunks of ...
-1
votes
2
answers
390
views
what is difference between less and cat with respect to reading binary files?
While I'm trying to read the file /var/log/boot.log with less, I will get the this message:
[amirreza@localhost ~]$ sudo less /var/log/boot.log
"/var/log/boot.log" may be a binary file. See ...
1
vote
2
answers
374
views
How to display stdout of command in `less` with as few keystrokes as possible?
I often find myself piping a command's output into less because less is far superior for studying the output than the normal terminal.
While I can always append | less to every command, I was ...
1
vote
1
answer
334
views
Does less Do Anything That zless Doesn't?
I've recently found the benefit of using zless to read log files that have rolled and been zipped.
Is there any functionality in less that isn't in zless that might catch me out if I alias less to ...
1
vote
0
answers
125
views
In Less, how to jump horizontally between search matches on the same line?
On pressing n, Less skips all the search matches in the current line and moves to the next line with a match (even if the lines are wrapped). How can I make it move the cursor to all the matches in ...
0
votes
0
answers
385
views
How to format text file to be readable in terminal
I thought this would be an easy question to find an answer to online, alas not.
In a nut shell I want to be able to open a text file to be formatted to be nicely readable in the terminal.
Background: ...
2
votes
1
answer
220
views
less in "tail -f mode" and ability to scroll horizontally at the same time
less -S is useful to have horizontal scrolling with arrow keys (like mentioned in Horizontal scrolling in smaller increments with less -S) instead of breaking long lines into multiple lines
less +F, ...
2
votes
1
answer
265
views
How to redirect ls output into `less -R` if the output size is large
If the count of ls output is more than 20 could it be redirected into less -R, in order the keep the bash clean. If its less than 20, the output could printed into the terminal.
When I do ls for ...
1
vote
0
answers
430
views
How to use less in a 'safe' way on files with huge lines?
I have a relatively large file, a minified json file which is about 4 Gigs. The file isn't huge...but a lot of programs choke on it because it's a single-lined file.
I have noticed less works ok on it ...