On Fri 15 Dec 2023 at 08:58:10 (-0500), Greg Wooledge wrote:
> On Fri, Dec 15, 2023 at 02:30:21PM +0100, Nicolas George wrote:
> > Greg Wooledge (12023-12-15):
> > > readarray -d '' fndar < <(
> > > find "$sdir" ... -printf 'stuff\0' |
> > > sort -z --otherflags
> > > )
>
Greg Wooledge (12023-12-15):
> Equally safe, perhaps. Not safer. I don't know those particular perl
> modules -- are they included in a standard Debian system, or does
> one need to install optional packages? And then there's a learning
> curve for them as well.
File::Find is a standard
On Fri, Dec 15, 2023 at 02:30:21PM +0100, Nicolas George wrote:
> Greg Wooledge (12023-12-15):
> > readarray -d '' fndar < <(
> > find "$sdir" ... -printf 'stuff\0' |
> > sort -z --otherflags
> > )
> It is possible to do it safely in bash plus command-line tools, indeed.
>
Greg Wooledge (12023-12-15):
> On Fri, Dec 15, 2023 at 01:42:14PM +0100, Nicolas George wrote:
> > Also, note that file names can also contain newlines in general. The
> > only robust delimiter is the NUL character.
>
> True. In order to be 100% safe, the OP's code would need to look
> more like
On Fri, Dec 15, 2023 at 01:42:14PM +0100, Nicolas George wrote:
> Also, note that file names can also contain newlines in general. The
> only robust delimiter is the NUL character.
True. In order to be 100% safe, the OP's code would need to look
more like this:
readarray -d '' fndar < <(
On 12/15/23, Greg Wooledge wrote:
> More to the point, bash has a 'readarray' command which does what you
> *actually* want:
>
> readarray -t fndar < <(find "$sdir" ...)
>
Yes, that was what I actually needed!
lbrtchx
Albretch Mueller (12023-12-15):
> sdir="$(pwd)"
> #fndar=($(IFS=$'\n'; find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
> %TI:%TM|%s\n' | sort --version-sort --reverse))
> #fndar=($(IFS='\n'; find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
> %TI:%TM|%s\n' | sort --version-sort --reverse))
> fndar=($(find
On Fri, Dec 15, 2023 at 12:33:01PM +, Albretch Mueller wrote:
> #fndar=($(IFS=$'\n'; find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
> %TI:%TM|%s\n' | sort --version-sort --reverse))
> the array construct ($( ... )) is using the space (between the date
> and the time) also to split array
sdir="$(pwd)"
#fndar=($(IFS=$'\n'; find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
%TI:%TM|%s\n' | sort --version-sort --reverse))
#fndar=($(IFS='\n'; find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
%TI:%TM|%s\n' | sort --version-sort --reverse))
fndar=($(find "$sdir" -type f -printf '%P|%TY-%Tm-%Td
9 matches
Mail list logo