[PLUG] Counting Files

David Fleck dcfleck at protonmail.ch
Tue Aug 17 12:41:00 UTC 2021


Ugh. Sorry, too little coffee.  Didn't notice this had already been covered.

--- David Fleck

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Tuesday, August 17th, 2021 at 7:39 AM, David Fleck <dcfleck at protonmail.ch> wrote:

> 'cut' might work well also.
>
> > ls | cut -f1 -d@ | sort | uniq -c
>
> to get a list in sort order, or
>
> > ls | cut -f1 -d@ |sort | uniq -c | sort -n
>
> to get a list ordered by frequency.
>
> --- David Fleck
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Tuesday, August 17th, 2021 at 1:46 AM, Russell Senior russell at personaltelco.net wrote:
>
> > From the uniq manpage:
> >
> > Note: 'uniq' does not detect repeated lines unless they are
> >
> > adjacent. You may want to sort the input first, or use 'sort -u'
> >
> > without 'uniq'. Also, comparisons honor the rules specified by
> >
> > 'LC_COLLATE'.
> >
> > On Mon, Aug 16, 2021 at 10:45 PM wes plug at the-wes.com wrote:
> >
> > > On Mon, Aug 16, 2021 at 8:45 PM Randy Bush randy at psg.com wrote:
> > >
> > > > can you point me to where it is documented that `find` is guaranteed
> > > >
> > > > to produce an ordered list?
> > >
> > > I don't have any such documentation or belief. my belief is that uniq will
> > >
> > > count non-consecutive matches, that's what I'm relying on. however, sorting
> > >
> > > first doesn't hurt anything, so have at it.
> > >
> > > yeah, awk is often a more appropriate tool for this type of job, it's just
> > >
> > > that I happened to learn sed first, so I default to that. it's the same
> > >
> > > reason I use vi instead of emacs, it's largely down to complete coincidence.
> > >
> > > -wes



More information about the PLUG mailing list