Skip to content

[feature request] select rightmost/trailing indices #57

@jskrzypek

Description

@jskrzypek

This might not be feasible, but I'd really like to be able to select rightmost/trailing fields from each line.
My use-case is for flattening an arbitrarily nested tree of files, where I only care about the parent directory and the filename of the files.

EX: Imagine this is the file structure

a
|-b
| |-c.jpg
| \-d
|   |-e.jpg
|   \-f.jpg
|-g
| |-h
| | \-i.jpg
| \-j.jpg
\-k.jpg

If I ran find ./a -type f -regex '.*\.jpg' on in the parent of a/ it would produce this output:

./a/b/c.jpg
./a/b/d/e.jpg
./a/b/d/f.jpg
./a/g/h/i.jpg
./a/g/j.jpg
./a/k.jpg

I want to generate the following output by selecting the 2 rightmost fiels from this input stream when splitting on / and joining on _ (i.e. quivalent to hck -d/ -D_ ...)

b_c.jpg
d_e.jpg
d_f.jpg
h_i.jpg
g_j.jpg
a_k.jpg

Would this be feasible? I can think of a couple signifiers for the potential option flag if it is, but my preference would be +f 2,1 (i.e. an inverted -f).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions