Linux – How to get file information in ‘less’ like with ‘man’

lesslinuxman

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)

Best Answer

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!

Related Question