[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sorting using two field separators
From: |
tolugboji |
Subject: |
Sorting using two field separators |
Date: |
Sun, 17 Oct 2021 20:03:50 +0000 |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, October 17th, 2021 at 7:36 PM, tolugboji <tolugboji@protonmail.com>
wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Sunday, October 17th, 2021 at 6:00 PM, tolugboji tolugboji@protonmail.com
> wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Sunday, October 17th, 2021 at 5:40 PM, Daniel Mills
> > danielmills1@gmail.com wrote:
> >
> > > 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.
> >
> > Fantastic, did not know that.
> >
> > "find" uses a null character. Could one make the awk command know that?
> >
> > find "$fdir" -type f -name "${fnam}-*.png" -print0 |
> >
> > awk -F'[-.]' '{print $(NF-1), $0}' |
> >
> > sort -znk 1,1 | cut -d ' ' -f2-
> >
> > echo
>
> Have included RS='\0' in the "awk" command to handle "-print0" in a previous
> "find".
>
> Things stop at the first entry, with no sorting performed.
>
> Code:
>
> find "$fdir" -type f -name "${fnam}-*.png" -print0 |
>
> awk -F'[-.]' '{print $(NF-1), $0}' RS='\0' |
>
> sort -znk 1,1 | cut -d ' ' -f2-
>
> Input:
>
> /home/flora/edvart/docs/schimmel-04.png
>
> /home/flora/edvart/docs/schimmel-05.png
>
> /home/flora/edvart/docs/schimmel-06.png
>
> /home/flora/edvart/docs/schimmel-07.png
>
> /home/flora/edvart/docs/schimmel-08.png
>
> /home/flora/edvart/docs/schimmel-09.png
>
> /home/flora/edvart/docs/schimmel-10.png
>
> /home/flora/edvart/docs/schimmel-11.png
>
> /home/flora/edvart/docs/schimmel-12.png
>
> /home/flora/edvart/docs/schimmel-13.png
>
> /home/flora/edvart/docs/schimmel-1.png
>
> /home/flora/edvart/docs/schimmel-2.png
>
> /home/flora/edvart/docs/schimmel-3.png
>
> Output:
>
> /home/flora/edvart/docs/schimmel-04.png
I also did ORS='\0' but still the thing does not budge
find "$fdir" -type f -name "${fnam}-*.png" -print0 |
awk -F'[-.]' '{print $(NF-1), $0}' RS='\0' ORS='\0' |
sort -znk 1,1 | cut -d ' ' -f2-
- Sorting using two field separators, tolugboji, 2021/10/17
- Re: Sorting using two field separators, Alex fxmbsw7 Ratchev, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Re: Sorting using two field separators, Daniel Mills, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Sorting using two field separators,
tolugboji <=
- Re: Sorting using two field separators, Alex fxmbsw7 Ratchev, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Re: Sorting using two field separators, Alex fxmbsw7 Ratchev, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Re: Sorting using two field separators, Dennis Williamson, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Sorting using two field separators, tolugboji, 2021/10/17
- Re: Sorting using two field separators, Alex fxmbsw7 Ratchev, 2021/10/18
- Re: Sorting using two field separators, Tapani Tarvainen, 2021/10/18