Re: Determination of file lists from selected folders without returning
From:
SF Markus Elfring
Subject:
Re: Determination of file lists from selected folders without returning directory names
Date:
Tue, 18 Jul 2017 10:17:38 +0200
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
>> I imagine that there are more advanced possibilities to improve the software
>> run time characteristics for this use case.
>
> Well, if it has to be fast, perhaps don't write the code in the shell
> language.
To which “shell” would you like to refer to?
> Even an interpreted scripting language that can do string handling without
> resorting to fork()-based command substitution will beat the shell at many
> tasks.
How do you think about additional approaches to reduce the forking of special
processes?
>> I would like to avoid such an operation “Remove matching prefix pattern”
>> generally.
>> If the desired file lists contain only basenames, extra prefixes do not need
>> to be deleted.
>
> I.e. we can use the basename function:
>
> for name in dir/*txt; do
> basename "$name"
> done
>
> prints the basenames of the matching files, one per line.
There is also the GNU variant available for such a command.
for X in $(basename --suffix=.txt dir/*txt); do my_work $X; done
But how often can it be avoided to delete extra data like prefixes (and
suffixes)?
Can it occasionally be a bit more efficient to provide only the essential
values at the beginning of an algorithm so that so they will be extended on
demand?
Regards,
Markus