1

When I view a file in Linux with the 'less' command, I often only get a ":" prompt in the bottom left corner. There's no clue about how long the file will be, or at which location I am currently. When reading manpages with 'man', there's a file title and line number in that corner. And once I hit the end of the file, there's even a percentage shown. I've learned about 'less -m' but it's not that powerful. So what does 'man' differently from 'less'? They appear to be the same viewing programme, except for that file information difference.

(Using Ubuntu 10.4 LTS)

3
strace man

reveals that it just calls pager.

man pager

reveals that pager is actually less. And indeed

$ ls -al /usr/bin/pager
lrwxrwxrwx 1 root root 23 2009-08-18 17:30 /usr/bin/pager -> /etc/alternatives/pager
lrwxrwxrwx 1 root root 13 2009-08-18 17:19 /etc/alternatives/pager -> /usr/bin/less

so less has some presets which are invoked when called by the name pager.

Actually strace also reveals these environment variables:

"LESSCHARSET=utf-8",
"LESS=-ix8RmPm Manual page less(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e 
(END):?pB %pB\\%..$PM Manual page less(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e
(END):?pB %pB\\%..$",

So that's it!

  • Okay, I now found that there's a LESS environment variable and that you can specify "prompts" in less. But the manpage is so very complicated to read in that section that I probably do that later if at all. Or does anybody know a practical solution for that? Using the very environment variable from above doesn't change a thing for me. – ygoe Aug 9 '10 at 17:30
3

less -M will show current line information in the status area.

1

less is designed to work with a stream (a pipe) which length is normally not known. Man is always working on file, so it could always provide this information.

  • less can operate on files just fine. By default it shows the filename initially, and there are options that will make it show it constantly. – Matthew Flaschen Jul 31 '10 at 22:05
1

Have you tried looking at man less or typing (I think) H in less to see the gazillion options? I'd look it up for you but I'm not on a Linux machine at the moment.

1

Ctrl-G will give you some file stats at the bottom of the page.

0

That information comes from the LESS environment variable, which man populates. You can find the value in the man page for man. I recommend considering the most pager instead. You can do this by installing most and changing the PAGER environment variable. It has useful features like colorization, and will show the filename at all time by default.

0

On Ubuntu I tried Colorful man suggested on commandlinefu and have been satisfied.

0

add alias less='less -RM +Gg' to your .bashrc, adjust it if you are using fish-shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.