variable line-display pager?
Chip Camden
sterling at camdensoftware.com
Sun Feb 20 00:44:37 UTC 2011
Quoth Chip Camden on Saturday, 19 February 2011:
> Quoth Gary Kline on Saturday, 19 February 2011:
> > On Sat, Feb 19, 2011 at 03:52:40PM -0800, Chip Camden wrote:
> > > Quoth Gary Kline on Saturday, 19 February 2011:
> > > > Need help findind a way of using existing unix utilities to diplay
> > > > chunks of N lines of a text files. Here N <= the number of lines in
> > > > the file.
> > > >
> > > > For instance, say that my xterm/console/"Konsole" is 80x53 lines.
> > > > My text file is around 200 lines long and I want to use more or less
> > > > or some GUI pager to display only 15 lines at one time. Tapping the
> > > > space bar would display another 15 lines and so on until EOF. Is
> > > > there a way of doing with with flags of the existing /usr/bin/less
> > > > or is there some other pager that I can build?
> > > >
> > > > thanks,
> > > >
> > > > gary
> > > >
> > > >
> > > >
> > > > --
> > > > Gary Kline kline at thought.org http://www.thought.org Public Service Unix
> > > > Journey Toward the Dawn, E-Book: http://www.thought.org
> > > > The 7.98a release of Jottings: http://jottings.thought.org
> > > >
> > > > _______________________________________________
> > > > freebsd-questions at freebsd.org mailing list
> > > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > > > To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> > >
> > > The -z option is supposed to do this:
> > >
> > > less -z15 file.txt
> > >
> > > But it appears to work only on the second and successive pages.
> >
> >
> >
> > Oh. So _that's_ why. I tried less -m 15 [because the man pages
> > sais z=N; i just tried what you did with -z15. Full page first
> > time, 15 lines each spacebar thereafter.
> >
> > Zank you, Sir Chip.. Anybody else? I'm loathe to use anything gui,
> > but here's where I'll be happy w ith something GUI THat i can
> > squeeze my "15" or small-n lines' worth into. Can'y believe that
> > there is nothing for all theses years.... I mean, geewhiz!
> > Any idea where I Should look in ports or how to google this?
> >
> >
> > gary
> >
> > >
> > > --
> > > Sterling (Chip) Camden | sterling at camdensoftware.com | 2048D/3A978E4F
> > > http://chipsquips.com | http://camdensoftware.com | http://chipstips.com
> >
> >
> >
> > --
> > Gary Kline kline at thought.org http://www.thought.org Public Service Unix
> > Journey Toward the Dawn, E-Book: http://www.thought.org
> > The 7.98a release of Jottings: http://jottings.thought.org
> >
> > _______________________________________________
> > freebsd-questions at freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
> Is this sort of what you're looking for?
>
> #!/usr/bin/env ruby
> require 'optparse'
>
> pagesize = 15
>
> optparse = OptionParser.new do |opts|
> opts.banner = 'usage: npg [-n pagesize] file...'
>
> opts.on('-n', '--numlines pagesize', 'Specify page size in number of lines') do |n|
> pagesize = n.to_i
> end
>
> end
>
> begin
> optparse.parse!
> rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
> puts e
> puts optparse
> exit 1
> end
>
> loop do
> pagesize.times do
> if line = gets
> puts line
> else
> exit
> end
> end
> print "More..."
> STDIN.getc
> end
>
> --
> Sterling (Chip) Camden | sterling at camdensoftware.com | 2048D/3A978E4F
> http://chipsquips.com | http://camdensoftware.com | http://chipstips.com
Oops -- code corrected above.
--
Sterling (Chip) Camden | sterling at camdensoftware.com | 2048D/3A978E4F
http://chipsquips.com | http://camdensoftware.com | http://chipstips.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20110220/ce5266be/attachment.pgp
More information about the freebsd-questions
mailing list