SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-09-14 18:52:33

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

less -X is more

when reading about linux-commands, you are sure to come across the saying 'less is more', which is meant to mean that the program 'less' is better than the program 'more' (ok, preferential, but it IS said)
the easiest way to encounter 'less' is by viewing man pages (in #! at least). but when you use the 'q' command to quit 'less', the screen is cleared of the man page text as if nothing ever happened. 'more' does not have this behavior, so i did:

PAGER="more"

however, i soon found out the reason why 'less is more': 'more' does not allow you to scroll up and down through the file as easy as 'less' does. so, i figured, maybe 'less' has an option to not clear the screen after exiting. and as it turns out, it does! so, i did:

PAGER="less -X"

maybe this little tip is of use to someone!

Last edited by rhowaldt (2011-09-14 18:53:17)

Offline

Be excellent to each other!

#2 2011-09-14 19:03:40

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: less -X is more

I prefer most…

Offline

#3 2011-09-14 19:07:13

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: less -X is more

Hence the name less. There was more, but it wasn't enough. Unix devs love playing with words.

For manpages, I recommend most. Install it and export it as the pager. You'll be amazed.


I'm so meta, even this acronym

Offline

#4 2011-09-14 19:37:03

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

Awebb wrote:

Hence the name less. There was more, but it wasn't enough. Unix devs love playing with words.

For manpages, I recommend most. Install it and export it as the pager. You'll be amazed.

What is a "pager"
How do you "export it a the pager?"
how does one use "more" or "less" or "most" to read a man page?

I use a bash script: manp

thmb_manp-most.png

#!/bin/bash
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#See <http://www.gnu.org/licenses/>.

# USAGE:
# manp foobar

# check to see if running from a terminal
[ -t 0 ] && [ -t 1 ] || { zenity --warning --text="${0}: this script must be run from a terminal." ; exit 1 ;}

# cd to man page directory
cd /media/5/Documents/manPages

# gets "topic" (ie: foobar) from commandline
topic="$1"

# if "topic.txt" exists read it with gedit
    if [ -e ${topic}.txt ] ; then
        gedit ${topic}.txt &
    else
# if topic.txt does not exist - create it
    man --pager=cat --encoding=utf8 $topic >${topic}.txt

# check to see if "foobar.txt is > 0 bytes and if true reads it
# with gedit
        if [ -s ${topic}.txt ] ; then
            gedit ${topic}.txt &

# if topic.txt is 0 bytes - delete the created file.
        else
        rm ${topic}.txt
    fi
fi
exit

Last edited by Sector11 (2011-09-14 19:39:34)


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#5 2011-09-14 20:14:58

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: less -X is more

if one says "export", he's talking about a variable.

export PAGER='most'

Type it in bash and try a manpage. You can also put that line in your .bashrc to have it always.


I'm so meta, even this acronym

Offline

#6 2011-09-14 21:14:22

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 561

Re: less -X is more

@sector11
"man" is the standard program to read man-pages. and as "man man" (the manual page for man) states it uses PAGER to determine which program to use in order to display the page (default is normally less)
And a pager is a program which will display text files or the like in a scrollable way (like pages). try "more some/text/file" or "less some/text/file"

Offline

#7 2011-09-14 21:14:27

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: less -X is more

Awebb wrote:

Hence the name less. There was more, but it wasn't enough. Unix devs love playing with words.

For manpages, I recommend most. Install it and export it as the pager. You'll be amazed.

Thanks, I had no idea this gem even existed.

Offline

#8 2011-09-14 21:48:53

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

Awebb wrote:

if one says "export", he's talking about a variable.

export PAGER='most'

Type it in bash and try a manpage. You can also put that line in your .bashrc to have it always.

OK I have the lines in my bashrc:

# use most
export PAGER='most'

Now what?

  18:41:03 ~
         $ most df
df: No such file or directory

  18:41:08 ~
         $ 

Never mind - I'm such a noob!!

thmb_noob.png

Now that I can get used to!  Much better than "manp" and clears HDD space.


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#9 2011-09-14 22:06:38

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

Hi luc .. good to see ya.

I know about "man" ... been using it forever, but didn't like the terminal output

luc wrote:

@sector11
"man" is the standard program to read man-pages. and as "man man" (the manual page for man) states it uses PAGER to determine which program to use in order to display the page (default is normally less)
And a pager is a program which will display text files or the like in a scrollable way (like pages). try "more some/text/file" or "less some/text/file"

gotta be careful of which file:

  18:49:51 ~
         $ file:///home/sector11/Odds_&_Ends.txt
[1] 4763
bash: _Ends.txt: command not found
bash: file:///home/sector11/Odds_: No such file or directory
[1]+  Exit 127                file:///home/sector11/Odds_

  18:49:53 ~
         $ more ~/Odds_&_Ends.txt
[1] 5083
bash: _Ends.txt: command not found

[1]+  Stopped                 more ~/Odds_

  18:51:33 ~
         $ more ~/pstree.txt
  12:30:44 ~
         $ pstree
init─┬─atd
     ├─avahi-daemon───avahi-daemon
     ├─5*[conky]
     ├─conky───sh───python2.6
     ├─conky───2*[{conky}]
     ├─console-kit-dae───63*[{console-kit-da}]
     ├─cron
     ├─cupsd
     ├─2*[dbus-daemon]

OK, it's official - I like MOST!!!!!

thmb_more-less-most.jpg

say goodbye to "manp"

Last edited by Sector11 (2011-09-14 22:07:12)


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#10 2011-09-14 22:08:59

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

@ Awebb --

THANK YOU!  Nice stuff


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#11 2011-09-14 22:17:37

AwesomeFist
#! Die Hard
From: Dungeons of Doom
Registered: 2011-01-02
Posts: 668

Re: less -X is more

Awebb wrote:

Hence the name less. There was more, but it wasn't enough. Unix devs love playing with words.

For manpages, I recommend most. Install it and export it as the pager. You'll be amazed.

If less is more, then that would make more less, but if more is less and less is more, wouldn't that make more more?


"Of course it's happening inside your head, Harry, but why on earth should that mean that it is not real?" -Albus Dumbledore

Offline

#12 2011-09-14 22:20:06

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 561

Re: less -X is more

@s11
be careful to escape the ampersand in filenames. ampersand is a special character in the shell, if you put it after a command that command will be executed in the background. you might have seen it in the autostart.sh file.
execute:

sleep 10
sleep 10 &
jobs

Last edited by luc (2011-09-14 22:20:24)

Offline

#13 2011-09-15 03:11:22

rstrcogburn
CrunchRanger
From: New Mexico
Registered: 2010-06-12
Posts: 1,932
Website

Re: less -X is more

Did not know thanx


That hawk just kept flying! -Ben Lilly

Offline

#14 2011-09-15 03:22:47

AwesomeFist
#! Die Hard
From: Dungeons of Doom
Registered: 2011-01-02
Posts: 668

Re: less -X is more

luc wrote:

@s11
be careful to escape the ampersand in filenames. ampersand is a special character in the shell, if you put it after a command that command will be executed in the background. you might have seen it in the autostart.sh file.
execute:

sleep 10
sleep 10 &
jobs

And that is probably why the demons in nethack look like ampersands.

Last edited by AwesomeFist (2011-09-15 03:23:57)


"Of course it's happening inside your head, Harry, but why on earth should that mean that it is not real?" -Albus Dumbledore

Offline

#15 2011-09-15 05:27:08

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: less -X is more

Sector11 wrote:

@ Awebb --

THANK YOU!  Nice stuff

I'd like to thank the Academy.


AwesomeFist wrote:

If less is more, then that would make more less, but if more is less and less is more, wouldn't that make more more?

It is. I calculate boolean by multiplying with 0 and incrementing once. I love to see the truth.


I'm so meta, even this acronym

Offline

#16 2011-09-15 14:25:24

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 12,179

Re: less -X is more

Awebb wrote:

if one says "export", he's talking about a variable.

export PAGER='most'

Type it in bash and try a manpage. You can also put that line in your .bashrc to have it always.

...or you can

update-alternatives --config pager

choose 'most' from the list, and be done with it. tongue


I'm a moderator here.  How are we doing?  Feedback is encouraged.

Offline

#17 2011-09-15 14:25:38

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

luc wrote:

@s11
be careful to escape the ampersand in filenames. ampersand is a special character in the shell, if you put it after a command that command will be executed in the background. you might have seen it in the autostart.sh file.
execute:

sleep 10
sleep 10 &
jobs

Yea, I should have known that because I'm always using:

killall conky && conky -c ~/conky/someconky &

for testing purposes ... it was just a bad choice of a file to test with  big_smile


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#18 2011-09-15 14:29:41

dubois
The Old Codger
Registered: 2010-09-03
Posts: 2,238

Re: less -X is more

pvsage wrote:
Awebb wrote:

if one says "export", he's talking about a variable.

export PAGER='most'

Type it in bash and try a manpage. You can also put that line in your .bashrc to have it always.

...or you can

update-alternatives --config pager

choose 'most' from the list, and be done with it. tongue

My preferred method, too.  Do it the easy way first, if that doesn't work then rtfm.  neutral  wink

Offline

#19 2011-09-15 14:30:50

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: less -X is more

hey cool, did not know about 'most'. does it do the scrolling stuff like 'less', and does it also not clear the screen, like 'most'? because that is all i wanted in the first place.

Offline

#20 2011-09-15 14:34:45

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,434
Website

Re: less -X is more

pvsage wrote:
Awebb wrote:

if one says "export", he's talking about a variable.

export PAGER='most'

Type it in bash and try a manpage. You can also put that line in your .bashrc to have it always.

...or you can

update-alternatives --config pager

choose 'most' from the list, and be done with it. tongue

Interesting that lets me see it, but needed a sudo to do it.


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQ Linux

Offline

#21 2011-09-15 14:37:44

mynis01
#! Die Hard
From: 127.0.0.1
Registered: 2010-07-02
Posts: 1,963

Re: less -X is more

Omg I have colorized man pages now that I can scroll one line at a time. *mind blown*

Offline

#22 2011-09-15 14:54:12

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 12,179

Re: less -X is more

@rhowaldt:  As far as I can tell, most is just a Turnerized more.


I'm a moderator here.  How are we doing?  Feedback is encouraged.

Offline

#23 2011-09-15 15:08:12

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: less -X is more

Ah, that debian specific configuration is mostly strange to me. I prefer to have anything bash relevant in .bashrc, but if it works, it works :-D


I'm so meta, even this acronym

Offline

#24 2011-09-15 16:16:18

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: less -X is more

just tried out 'most'... clears the screen after pressing 'q', and does not even seem to have an option to stop doing that. so i'm wondering why this discussion has turned to 'most' like that, when my initial post is about acquiring functionality that 'most' does not provide... seems like a colorized version of 'less', with less options. unless i am overlooking something, i don't think the name 'most' is justified.

Offline

Help fund CrunchBang, donate to the project!

#25 2011-09-15 16:44:25

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,847
Website

Re: less -X is more

Also just switched to most, but would appreciate some pointers as to where the awesomeness lies as compared to less.


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo