how to get rid of wc's last total line
- From: Florian Kaufmann <sensorflo@xxxxxxxxx>
- Date: Mon, 17 Oct 2011 05:41:58 -0700 (PDT)
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.
.
- Follow-Ups:
- Re: how to get rid of wc's last total line
- From: bsh
- Re: how to get rid of wc's last total line
- From: Wayne
- Re: how to get rid of wc's last total line
- From: Kaz Kylheku
- Re: how to get rid of wc's last total line
- From: kax
- Re: how to get rid of wc's last total line
- From: Stephane CHAZELAS
- Re: how to get rid of wc's last total line
- From: Janis Papanagnou
- Re: how to get rid of wc's last total line
- Prev by Date: Re: (Newbie) Match from pattern1 to pattern2, but ignore pattern2 in between
- Next by Date: Re: how to get rid of wc's last total line
- Previous by thread: (Newbie) Match from pattern1 to pattern2, but ignore pattern2 in between
- Next by thread: Re: how to get rid of wc's last total line
- Index(es):
Relevant Pages
|