4 ms·
I'd really like if the "find" command supported this much easier, so if I write find some/dir/here -name '*.gz' then I could get the filenames without the
by silvestrov 2y ago
I'd really like if the "find" command supported this much easier, so if I write
find some/dir/here -name '*.gz'
then I could get the filenames without the "some/dir/here" prefix.
It would also be nice if "find" (and "stat") could output the full info for a file in JSON format so I could use "jq" to filter and extract the needed info safely instead of having to split whitespace seperated columns.
- ykonstant 2y agoWhy would you do this work when stat (and GNU find) can `printf` the exact needed information without any parsing?
- deleted 2y ago[deleted]
- silvestrov 2y agoIf I need filesize and filename then I still need to parse a filename that might contain all kinds of weird ascii control characters or weird unicode. JSON makes that a lot less fragile.
- ykonstant 2y agoI don't get it; I need a concrete example.
- williamcotton 2y agoWhat about: find . -name '*.hs' -exec basename {} \;
- rascul 2y agoYou could get mixed up here because find is recursive by default and basename won't show that files might be in different subdirectories.
- genrilz 2y agoIt's at least pretty easy to shorten the filenames: cd some/dir/here find . -name '*.gz' cd - # changes back to previous directory