help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting using two field separators


From: Daniel Mills
Subject: Re: Sorting using two field separators
Date: Sun, 17 Oct 2021 13:40:12 -0400

On Sun, Oct 17, 2021 at 1:19 PM tolugboji <tolugboji@protonmail.com> wrote:

> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Sunday, October 17th, 2021 at 4:59 PM, tolugboji via <help-bash@gnu.org>
> wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Sunday, October 17th, 2021 at 4:47 PM, Alex fxmbsw7 Ratchev
> fxmbsw7@gmail.com wrote:
> >
> > > maybe go a sideway, convert the filenames batchly into has-one-sep,
> then sort, then change back
> > >
>
> I can use awk to use two field delimiters.  But this still requires a
> little tweak to
> handle possibility of newlines.
>
> find "$fdir" -type f -name "${fnam}-*.png" -print0 |
>   awk -F'[-.]' '{print $(NF-1), $0}' |
>   sort -znk 1,1 | cut -d ' ' -f2-
>
>
>
 A second separator isn't needed here anyway, sort will just go by the
numbers and ignore the rest afterward.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]