how to get rid of wc's last total line



When I want to interpret the output of wc as a table, the last line
with the total is a problem, because it doesn't fit the pattern that
the last column is a file name. Say I want to find files which
contains a lot of lines

find ... | xargs wc -l | sort -nr
Here I have the "total" lines which I don't want

find ... | xargs wc -l | head -n -1 | sort -nr
Does not work if there are a lot of files and thus xargs has to invoke
wc multiple times resulting in multiple total lines.

find ... | xargs wc -l | grep -iv '\btotal$' | sort -nr
I don't want that because I want a 'perfect' solution (in order to
learn to deal with such problems) which allows files which are named
'total'

function my-wc() { wc "$@" | head -n -1 }
find ... | xargs my-wc -l | sort -nr
Here I have the problem, that xargs doesn't find my-wc. I don't want
to have a script "my-wc" in the PATH. The long-lines-searching-script
should be stand alone.


.



Relevant Pages

  • Re: how to get rid of wcs last total line
    ... with the total is a problem, because it doesn't fit the pattern that ... wc multiple times resulting in multiple total lines. ... that xargs doesn't find my-wc. ... restrictions but have *not* mentioned restrictions on tools I suggest ...
    (comp.unix.shell)
  • Re: OT: Obama up in all major polls
    ... I imagine this pattern of humiliating himself online with these ... ridiculous rants has repeated itself multiple times in addition to RSG. ... on the online golf forums that he has gotten himself banned from. ...
    (rec.sport.golf)
  • Re: First Paper Piece Block
    ... I prefold all my seam lines so I can see the outline of each piece on the ... back of the pattern also. ... I did oversize my pieces but I think the trouble I ... in the wrong direction so I ended up having to rip it multiple times. ...
    (rec.crafts.textiles.quilting)
  • Re: how to get rid of wcs last total line
    ... wc multiple times resulting in multiple total lines. ... that xargs doesn't find my-wc. ... A wc is not only built into the shell (modern ksh) itself, ... findcommand (also built in!), ...
    (comp.unix.shell)
  • Re: pipes ifs and suggestions
    ... I'm upon my first script i' writing mainly for exercitation than utility. ... It should search for a given pattern in a given text file and show the ... See the man pages for the details, in particular for xargs which is a bit ... echo error: ...
    (comp.unix.shell)