sdjf > commands > less
less
Command
The "less"
command
is similar to the "more"
command, but
much more powerful and efficient to use on the Zaurus and other Linux systems.
While both commands display the contents of a file,
one screenful at a time, "less"
enables the user to
skip to the beginning of a file with "g", skip to
the end of the file with "G", to search for a keyword
or phrase "/KEYWORD",
view the previous file with
":p", view the next file with ":n", and many, many
more things that we are unable to do with "more"
.
The syntax for using "less"
is similar
to the syntax for using the "cat"
command.
You can view just one file:
less myfile
Or you can view a set of files:
less file1 file2 file3 file4
Or a set of all files matching a specifed pattern:
less file*
You can view a list of all the options and commands that "less"
has by simply entering "less --help" from the command
line, or the letter "h" from within "less"
.
You can go to the next screen by pressing the space bar, the same as with "more."
But if you want to go back a screen, just enter a "w" for "window" and it will scroll up one screen. To exit "less"
, simply enter a "q" for "quit".
I had difficulty figuring out how to use "less"
to view the next or the previous
file. Since the command prompt inside of "less"
is a colon ":", how to invoke this feature was not at all obvious.
So, here are some hints about how to view the next file or the previous file, when you have given "less"
a list of files to open. After you see
the prompt, you must
enter a colon ":", followed by the letter "p"
to view the previous file, or followed by the letter
"n" to view the next file.
If you pay close attention before you enter any commands,
you will notice that the command prompt ":" in "less"
appears in the first column of the status line.
:
^
1st column
Then, when you enter a colon ":", the command prompt colon will disappear, and the colon you have entered will appear in the second column on your screen.
:
^^
2nd column
When you enter ":n" or ":p", the command you enter will not appear. Instead, navigation information will appear in the status line.
For example, if I am reading the second file (trial2.html) in a set of eight files, and want to look at the next file, trial3.html, and then go back to look at the second file again, trial2.html, I would do the following:
Enter the ":f" command to show the name of the current file:
:f
^^^
My status bar will display:
trial2.html (file 2 of 8) line 1/67 byte 400/743 53% (press RETURN)
When I am done viewing this file for now, I can enter the ":n" command for next file:
:n
^^^
My status bar will display:
trial3.html (file 3 of 8)
When I am done viewing the current file for now, I can enter the ":p" command for previous file:
:p
^^^
My status bar will display:
trial2.html (file 2 of 8)
"Less"
has many more useful features than I have had time to explore or to
figure out how to use. I will add tips
about how to use more of it's features as I have the time and/or get them figured out.
I extracted the copy of "less"
that I am running on my Zaurus, from
the arm
utilities package, available
at:
http://quickening.zapto.org/ZaurusFeed/Non-IPKs/armutils.tgz
You can get a gzipped copy of the "less"
binary I am using on both my sl5500, on Sharp ROM 2.38,
as well as on my sl6000L, running Sharp ROM 1.12,
, at:
http://www.sdjf.esmartdesign.com/files/less.gz
bash-2.05# md5sum less.gz
b32dc09387f29d20f40712b0a4742691 less.gz
bash-2.05#
There also appears to be an ipk on the following
feeds
, but I do not know which ROMs it will work on:
It seems likely to work on Sharp ROMs, but I cannot guarantee it.
http://www.oesf.org/howto/feed/less_1.0_arm.ipk
http://www.ossh.com/zaurus/feed/less_1.0_arm.ipk
http://www.sockmuppet.com/howto/zaurus_packages/packages/less_1.0_arm.ipk
It may be a copy of the less_1.0_arm.ipk
compiled for arm
devices, which is described at:
http://www.zaurususergroup.org/feed/Packages
It depends on libncurses.so.5, libc.so.6, and on ld-linux.so.2. In case your ROM does not include libncurses.so.5, I have put a gzipped copy of the latter at:
http://www.sdjf.esmartdesign.com/files/libncurses.so.5.0.gz
The above version of libncurses.so.5 will need to be gunzipped before use. It runs on both my Collie with Sharp ROM 1.38 and on my Tosa Sharp ROM 1.12. Some applications require the library to be called libncurses.so.5 instead of libncurses.so.5.0, you can just create a symlink to achieve equivalence. If you run the following, packages looking for libncurses.so.5.0 will be satisfied to use libncurses.so.5
ln -s /home/QtPalmtop/lib/libncurses.so.5.0 /home/QtPalmtop/lib/libncurses.so.5
The libncurses.so.5 library can also be obtained from the arm utilities package mentioned above.
Revised December 6, 2012