less is a terminal pager program on Unix, Windows, and Unix-like systems used to view (but not change) the contents of a text file one screen at a time.

learn more… | top users | synonyms

132
votes
4answers
30k views

How to turn off word-wrap in less

Short version: How can I make the less utility in Linux not wrap lines? Long version: Often I need to view huge CSV files using less with hundreds of columns. I frequently only care about the first ...
94
votes
10answers
42k views

Get colors in 'less'' command

when I read a file in Linux with the command 'less' or 'more', how can I get the content in colors?
94
votes
5answers
20k views

Less and Grep: Getting colored results when using a pipe from grep to less

I use the --colour option of grep a lot, but I often use less as well. How can I pipe grep results to less and still preserve the coloring. (Or is that possible?) grep "search-string" -R * --colour | ...
72
votes
3answers
19k views

less command with multiple files: How to navigate to next/previous

I just found out I can use less with multiple files. less status line tells me (END) - Next: file2.txt But how do I navigate previous/next from less?
54
votes
10answers
18k views

How to syntax highlight via Less

is there a way to syntax highlight a file I see in Less? actually I'm using this command to open an xml file (and sometimes a series of them) less htmleditors/htmleditors_config.xml or less ...
46
votes
3answers
15k views

less is more? Is more less? I'm so confused

When I first heard their names, I got really confused when I tried to guess what these tools might do, I thought I'd misheard something. What's the difference between more and less, i.e. why ...
36
votes
1answer
21k views

Less: Quickly Jump to Line Number in Large File

I'm struggling to figure out a way to do this...I'm using less to view a large (~1GB) file. I want to jump to line "$n" in the file - preferably without having to wait for lines 1-($n-1) to scroll by ...
31
votes
5answers
5k views

How can I save the current contents of less to a file?

If I've piped the results of a command to less and then decided that I want to save the contents to a file, is this possible? I've tried setting a mark a at the end of the buffer, and then returning ...
22
votes
6answers
4k views

Mercurial. Colour output piped to less

Operating system: Mac OS 10.6.2 I'd like to be able to see colour output when piping certain commands through less. Two examples: I've got ls aliased to ls --color=auto, so I'd like to be able to ...
11
votes
2answers
4k views

Mouse wheel scrolling in less and vim using urxvt

I have started working with rxvt-unicode (aka urxvt) but found an issue with mouse-wheel scrolling, as compared to gnome-terminal and konsole. The mouse wheel works fine for going through the ...
10
votes
2answers
12k views

Less or More in Windows?

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 ...
9
votes
1answer
2k views

How do i get the git pager to act normal?! Less leaves output on the screen when executed via git

The pager less doesn't clear the screen as it should do when i use git. I use less all the time and it usually doesn't leave output in the terminal after quit but when less gets executed via git it ...
9
votes
3answers
2k views

Why does less tail mode stop working?

Using the less command on linux in tail mode (F command or less -f) consistently stops working on certain machines and/or certain files. New changes simply stop showing up. I know I've fixed this ...
8
votes
2answers
872 views

In Unix “less”, can I jump to the next line that does NOT contain X?

In the Unix less tool, is it possible to jump to the next line that does not contain a certain expression? I sometimes have to look through files that contain thousands of similar adjacent lines ...
8
votes
1answer
3k views

How to make mouse wheel scroll the less pager using bash and gnome-terminal?

I have two computers with the latest Fedora. On the first, I'm using zsh and the mouse wheel can be used with the less pager within gnome-terminal to scroll the pager. On the second, I use bash and ...
8
votes
1answer
2k views

How do I include newlines in a search in less?

How can I search for newlines (or end of lines) as part of a search using less? For example, I'd like to search for length=9\n, but don't want to merely search for length==9 because that'd get ...
7
votes
1answer
286 views

Getting LESS to return back to command line if a short file is displayed

Is there a command line option that will allow less to return to the command line if there are not sufficient lines in the file to warrant paging. Sure I have seen it in the past but can't find the ...
7
votes
2answers
858 views

copy and paste tabs between terminal windows in X11

When I copy and paste text using the X11 mouse selection between two terminal windows, tabs are often, but not always, converted to spaces. This appears to depend on the involved terminal ...
6
votes
3answers
2k views

How do you search for tabs in the linux command less?

How do you search for tabs in the linux command less? I've tried /\t but that only seems to search for the character t.
6
votes
3answers
328 views

Is there an automatically scrolling, time-delayed Unix pager command?

I'd like to view output of big commands slowed down, like a slideshow with e.g. automatic, 500ms delay between each scroll. What is the simplest way to achieve this?
5
votes
2answers
337 views

Let less work like cat, if only one screen full of text

On my Debian machine here, less always opens the alternate screen to show stuff. This is annoying, if there are only 2 or 3 lines to be displayed. I'd like less to: work as pager, if there is more ...
5
votes
1answer
246 views

How to center search results in Less, instead of moving matched line to top of terminal

When searching for terms in less, I'd like to see lines above and below a search result. Can less be configured to do this? Simple less usage is: - Open file - Search by typing "/" - Move to new ...
4
votes
4answers
5k views

How do you run `less` and have it run a search pattern automatically?

I'm trying to run less in Linux, and I want it to search for something immediately after launch. It's basically like doing this: $ less Then press '/', type a search pattern like "^commit \w+$", ...
4
votes
3answers
529 views

Incremental searching with the `less` utility

Does less have an incremental search? I'm on xubuntu.
4
votes
2answers
409 views

on quit, 'less' does NOT clear its contents when run in a 'screen' session [duplicate]

Possible Duplicate: Using screen, commands like less and man don't clear the screen afterwards When I quit 'less' in a normal bash, it clears the previous contents displayed by 'less' ...
4
votes
4answers
1k views

Change less (pager) default options

I'm using Ubuntu 10.04. My default pager(set using update-alternatives, not $PAGER) is less. The problem is, when I use ri(Ruby documentation tool) with the '-f ansi' mode, less shows the escape ...
4
votes
2answers
5k views

LESS and CSS3 syntax highlighting

I found this post on SU, but it doesn't seem to address my needs exactly, so I'll ask a similar question. I normally use PSPad, and I'm also not too scared of Notepad++. They are both good editors, ...
4
votes
1answer
207 views

Less hotkeys not working, printing keycodes instead performing action

When I try something like php -i | less Less is not responding to hotkeys, but prints them like pressing "q" results in statusline :q PageDown :^[[6~ Pressing ENTER like "executes" the ...
3
votes
6answers
1k views

Linux less behavior and stderr

I'm watching the output of my complicated command with less, problem is the stderr gets lost. stderr lines normally get listed inbetween stdout lines inside less. I would like them to be printed to ...
3
votes
4answers
2k views

LESS syntax highlighting in Geany

I'm using LESS CSS (PHP version). I'm also using Geany in Linux. Is there a LESS syntax file for Geany out there, or how I can go about editing the CSS one to suit LESS?
3
votes
4answers
603 views

Unix command to empty logfile from within “less”?

I prefer using "less" to reading logfiles. As opposed to "tail -f" I can both follow (Shift + F), stop (Ctrl + C), and navigate up and down u and d, etc. Now what I really would like is the ability ...
3
votes
3answers
451 views

Less interrupting in less

I often pipe program output to less, e.g. produce_output | less This works great, until produce_output produces large amounts of output. If I search for some text that is deep into the file, less ...
3
votes
2answers
500 views

How do I execute a Linux command whilst using the less command or within the man pages?

I generally pipe the command ls with less and would like to execute a command while it is paging e.g. I come across a file that I would like to delete so I would like to execute the command rm ...
3
votes
3answers
3k views

How to copy text from less

How might one copy the entire buffer being displayed by less? No need to select specific text, I want it all. Copying to the clipboard is preferable but if we can output it to a file that works too. ...
3
votes
3answers
545 views

Viewing zip archive contents using 'less' on OS X

I couldn't help but notice that the 'less' program on all of the recent distributions of Linux that I've used (Ubuntu and Gentoo in this case) allow me to view the contents of ZIP and TAR archives, ...
3
votes
2answers
657 views

Ctrl+c in a sub process is killing a nohup'ed process earlier in the script

I didn't know whether this belonged on SO (as it is a coding bug) but thought you guys would be more knowledgeable regarding the subtleties of the software used (so maybe even U&L could be ...
3
votes
2answers
304 views

How can I have `less` automatically decompress `xz` files like it did with `gz` files on my old SUSE distro?

On my old SUSE distro, less would automatically decompress .gz files. That came in very convenient when listing auto-compressed /var/log/mail*.gz files. The current version of SUSE now archives ...
3
votes
1answer
165 views

How to do a multiline search in less?

In less, can you search using / for a pattern that contains a carriage return and newline? I know your pattern can end with a line using $ (from How do I include newlines in a search in less?), but I ...
3
votes
2answers
550 views

The Less command can list directory contents in Gentoo Linux, but not in Ubuntu Linux

I regularly use the 'less' command in Gentoo like so: less /tmp (or any other directory, which I have access to.) Less then proceeds to show me the contents of that directory. I can also use Less to ...
3
votes
1answer
324 views

Why less -F option does not work with -S option

While trying to improve output from hg diff I've noticed that less -F option does not work with -S option. Why is that happening and how to achieve desired effect? Here is handout from man: -F or ...
3
votes
1answer
310 views

Tailing multiple files with less

I want to have the best of both worlds with tail and less. Following multiple files, like tail can, but also having the scrollable buffer of less. So, I tried: tail -f mylog1 mylog2 | less +F But ...
3
votes
1answer
140 views

Why does cd print when run in command substitution?

If I use the 'cd' BASH built-in in a command substitution, it prints extra stuff to stdout, but only when piped to, eg., less. $ echo `cd .` # The output is a single newline, appended by echo. $ ...
2
votes
2answers
287 views

PHP output piped to 'less' is requiring <enter> after every command

Piping PHP output to the linux 'less' command causes 'less' to really act up. (CentOS 6.2, didn't happen with CentOS 5.) When I pipe output from php into 'less', it requires the enter key be pressed ...
2
votes
3answers
1k views

How can I tell kate to use CSS highlighting for .less files by default?

How can I tell kate to use CSS highlighting for .less files by default?
2
votes
3answers
2k views

Terminal pager: How to display a list in columns?

I'm sure it's very simple, but I can't remember how to tell a terminal pager (more/less/pg/most) to display a long list in columns. Since my input is just a list of short elements, displaying it the ...
2
votes
1answer
145 views

vim doesn't display first line?

when I use vim to open some php files, it starts with line 2, other files display fine. When I view the file with less I have the same issue. however when I edit it with nano I can see that line's in ...
2
votes
2answers
229 views

Lessc Textmate bundle doesn't save .css file

I installed: https://github.com/appden/less.tmbundle and the lessc compiler and it seems to work (no errors) but I don't see a compiled .css file. Any ideas?
2
votes
2answers
153 views

Can I display a text file in multiple vertical panes?

I've got a text file with lots of 60 character long lines where I do a search with the "/" command to highlight the hits. I would like to visually inspect this long file with the highlighted text but ...
2
votes
1answer
525 views

less tail mode + pipes?

Why doesn't less's tail/scroll mode work with pipes? For example, I'd like to make a build script pipe to less in order to make the output of the build script scrollable. So... make | less +F ...
2
votes
1answer
561 views

'less' doesn't clear screen after quit

The default behavior for 'less' is to clear the screen after quitting. This behavior stopped when I started using: export TERM=xterm Now 'less' leaves the last page I viewed on the screen, and I ...