Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread David Wright
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 > > > ) >

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Nicolas George
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

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Greg Wooledge
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. >

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Nicolas George
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

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Greg Wooledge
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 < <(

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Albretch Mueller
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

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Nicolas George
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

Re: setting IFS to new line doesn't work while searching?

2023-12-15 Thread Greg Wooledge
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

setting IFS to new line doesn't work while searching?

2023-12-15 Thread Albretch Mueller
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