Re: Blank lines not being squeezed
From: Fred Ma (fma_at_doe.carleton.ca)
Date: 03/26/04
- Previous message: Lew Pitcher: "Re: Do too many files hurt a directory?"
- In reply to: Chris F.A. Johnson: "Re: Blank lines not being squeezed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Mar 2004 18:12:23 GMT
"Chris F.A. Johnson" wrote:
>
> >> > I was using various methods to turn a few man pages
> >> > into compact text pages. In bash notation:
> >> >
> >> > man man | PAGER -s | col -bx >| TextFile.txt
> >>
> >> man man | col -bx | tr -s '\n' >| TextFile.txt
>
> > Thanks for pointing out the tr command. I wonder,
> > though, why "more" or "less" would not behave in the way
> > that I expected when its output is piped or redirected?
>
> I don't see any documentation regarding it, but I believe that
> nothing is done to the file when output is not to a terminal.
>
> > They do a nice job otherwise, because the single blank
> > line they leave behind helps to space things out a bit.
>
> Use cat -s instead of tr -s "\n".
>
> If your cat doesn't have the -s option (it's not in POSIX, but
> all versions I've seen do have it), use this awk script:
>
> awk '
> /^$/ && ++empty > 1 { next }
> /./ { empty = 0 }
> { print }
> '
>
> Incidentally, if you just want to view a man page without multiple
> blank lines, since man already pipes the file through $PAGER, you
> can give it the option this way (if $PAGER-less):
>
> LESS="$LESS -s" man man
>
> Or (if $PAGER=more):
>
> MORE="$MORE -s" man man
Actually, I was only using more/less to squeeze out blank
lines because "cat -s" only squeezes out blank lines on one
of the two systems I work with (cygwin, but not solaris).
I've found that if I use gvim to pipe the file content to
these utilities (":%!more/less/cat -s"), it doesn't leave in
the extra lines that I see if I redirect their output to a
file from the command line. However, that's probably no
more efficient than your filter above. Thanks again.
Fred
- Previous message: Lew Pitcher: "Re: Do too many files hurt a directory?"
- In reply to: Chris F.A. Johnson: "Re: Blank lines not being squeezed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|