Re: Blank lines not being squeezed

From: Fred Ma (fma_at_doe.carleton.ca)
Date: 03/26/04

  • Next message: Roberto Quiroga: "Re: Do too many files hurt a directory?"
    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


  • Next message: Roberto Quiroga: "Re: Do too many files hurt a directory?"

    Relevant Pages

    • redirecting output of dos program in windows
      ... How can i redirect the output of a dos program to a text box. ... command also, ... I have used pipes in win32 assembly programming, ...
      (alt.lang.asm)
    • Re: Redirecting lpt1 output to an installed printer
      ... to the lpt1 port. ... I am doing now is to redirect the output using the "net use" ... If there's a recognized printer on that port, ... which I do via a "net use LPT1" command inside a batch file. ...
      (microsoft.public.vb.general.discussion)
    • Re: How to capture "legacy" program output in MSH and redirect them to MshHostUserInterface
      ... command is redirected in the script or not. ... to see if the output of the script command is the default output pipe. ... The workaround is to always explicitly redirect native ... RedirectAlways flag on the runspace that will cause legacy applications to ...
      (microsoft.public.windows.server.scripting)
    • Re: splice/tee bugs?
      ... testing using my modified version of your test program, ... command line: ... pipes are changed in between the _prep calls and link_pipe. ... Call Trace: ...
      (Linux-Kernel)
    • Re: Reading program output from stdin
      ... No pipes in Unix? ... > if the command does not write to stdout for some reason. ... > how to write robust code, ...
      (comp.lang.c)