[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Loop with files coming through sorted by name
From: |
Seth David Schoen |
Subject: |
Re: Loop with files coming through sorted by name |
Date: |
Fri, 15 Oct 2021 20:31:04 -0700 |
Seth David Schoen writes:
> Typically people will suggest instead using the find command, either
> with the -exec flag or with the -print0 flag. This is extensively
> described in
>
> https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
>
> A disadvantage there is that the command run by the -exec can only be
> a single command, not a bunch of shell scripting or even a pipeline.
I didn't realize, but there is a newer approach which involves a bunch of
historically recent bashisms
https://stackoverflow.com/questions/23356779/how-can-i-store-the-find-command-results-as-an-array-in-bash/54561526#54561526
You can thus do
readarray -d "" myarray < <$(find . -type f -print0 | sort -zn)
for i in "${myarray[@]}"; do
# arbitrary shell stuff with "$i"
done
Classical Bourne shell scripting it isn't. :-)
- Loop with files coming through sorted by name, tolugboji, 2021/10/15
- Re: Loop with files coming through sorted by name, Seth David Schoen, 2021/10/15
- Re: Loop with files coming through sorted by name,
Seth David Schoen <=
- Loop with files coming through sorted by name, tolugboji, 2021/10/16
- Re: Loop with files coming through sorted by name, Alex fxmbsw7 Ratchev, 2021/10/16
- Re: Loop with files coming through sorted by name, Kerin Millar, 2021/10/16
- Re: Loop with files coming through sorted by name, Greg Wooledge, 2021/10/16
- Loop with files coming through sorted by name, tolugboji, 2021/10/16
- Re: Loop with files coming through sorted by name, Daniel Mills, 2021/10/16
- Loop with files coming through sorted by name, tolugboji, 2021/10/16
- Re: Loop with files coming through sorted by name, Daniel Mills, 2021/10/16
- Re: Loop with files coming through sorted by name, Dennis Williamson, 2021/10/16
- Loop with files coming through sorted by name, tolugboji, 2021/10/16