I now aim to show the percentage sign also when you run, for example, the command
man emacs
If you run it, you get 'byte 3300' for instance.
Alex's answer suggests me that we need to make a separate shell function by
man "$1"| col -b > /tmp/manual
less /tmp/manual
where $1 refers to the first parameter.
The new problem is at the thread. Thanks to Yuliy for the crux move!
Percent reduction of area is a ration that expresses how much the specimen narrowed when compared to its original size. It is calculated by dividing the difference between the original and new cross-sectional areas at the point of failure by the original cross-sectional area of the test specimen.
First: work out the difference (increase) between the two numbers you are comparing. Then: divide the increase by the original number and multiply the answer by 100. % increase = Increase ÷ Original Number × 100. If your answer is a negative number, then this is a percentage decrease.
Percentage decrease is found by dividing the decrease by the starting number, then multiplying that result by 100%. Note: the percent decrease measures FROM the first value. A decrease from 50 of 25 is a change of 50% (25 is the difference between the two numbers, and 25 is 50% of 50)).
A less manual version of knitatoms' answer
combined with Alex Marteilli's answer
works quite well: pass the +Gg
option to less
via its pager option.
For example, try
man -P 'less -s -M +Gg' man
This can be effected permanently by putting
export MANPAGER='less -s -M +Gg'
in one of your shell configuration files (above syntax is for Bash and
ZSH). Now, for example, man man
displays the percentage as you
wanted!
You should not put the +Gg
in the LESS
variable! For example,
doing
export LESS='-M +Gg'
will cause problems when reading very large files. For example,
yes | LESS='-M +Gg' less
does not work very well ...
As other answers have explained, the problem is that less
can't say
what percent into the file you are until it knows how long the file
is, and it doesn't read to the end of the file by default when reading
from a pipe.
From the OPTIONS
section of man less
:
+ If a command line option begins with +, the remainder of that
option is taken to be an initial command to less. For exam‐
ple, +G tells less to start at the end of the file rather than
the beginning, and +/xyz tells it to start at the first occur‐
rence of "xyz" in the file. As a special case, +<number> acts
like +<number>g; that is, it starts the display at the speci‐
fied line number (however, see the caveat under the "g" com‐
mand above). If the option starts with ++, the initial com‐
mand applies to every file being viewed, not just the first
one. The + command described previously may also be used to
set (or change) an initial command for every file.
The g
means "return to the beginning of file".
From the man man
:
-P pager, --pager=pager
Specify which output pager to use. By default, man uses pager
-s. This option overrides the $MANPAGER environment variable,
which in turn overrides the $PAGER environment variable. It
is not used in conjunction with -f or -k.
The value may be a simple command name or a command with argu‐
ments, and may use shell quoting (backslashes, single quotes,
or double quotes). It may not use pipes to connect multiple
commands; if you need that, use a wrapper script, which may
take the file to display either as an argument or on standard
input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With