Is this correct behaviour for 'rev'?

Backwoods BC completely.and.totally.trash@gmail.com
Mon Nov 4 21:20:55 GMT 2024


On Mon, Nov 4, 2024 at 9:49 AM ASSI via Cygwin <cygwin@cygwin.com> wrote:
>
> Backwoods BC via Cygwin writes:
> > cat fileOfFullPathNames | rev | sed -r -e "s/\./$mySep/" | rev | sort
> > -t "$mySep" --key=2.1 | tr "$mySep" '.'
>
> $ <fileOfFullPathNames sed -E 's/[.]([^.]+)$/\x00\1/' | sort -t '\0' -k2 | tr '\0' .

Thanks, Achim! That's simpler and avoids 'rev' and its quirks. \x00
will be a problem for ASCII in Unicode and need to avoid sorting on
directory names, so a slight change:
<fileOfFullPathNames sed -E 's/[.]([^./]+)$/\x01\1/' | sort -t '\001'
-k2 | tr '\001' .


More information about the Cygwin mailing list