Skip to main content
13 events
when toggle format what by license comment
Jan 5, 2024 at 10:26 vote accept symcbean
Jan 5, 2024 at 10:13 comment added Stéphane Chazelas File names do not contain NULs be contain newlines and command substitution strip trailing newline characters. That would only be a problem with things like find $'\n\n\n' ... though.
Jan 5, 2024 at 10:11 comment added Stéphane Chazelas Beware -mtime +1 is not the complement of -mtime -1. '(' -mtime 1 -o -mtime +1 ')' would be.
Jan 5, 2024 at 10:10 comment added Stéphane Chazelas Using A && B || C in place of if A; then B; else C; fi is really bad practice, I wish people didn't advertise its usage here.
Jan 5, 2024 at 10:09 comment added Stéphane Chazelas Invoking split+glob on the output of find in findResults=( $(find . -mtime -1 -iname '????*' | head -n1) ) makes little sense definitely a lot less than doing [ -n "$(find... |head -n1)" ].
Jan 5, 2024 at 10:08 comment added Stéphane Chazelas @FelixJN, no that would likely not help as find will buffer its output, so will print those 2 lines at once. Even if it didn't it's unlikely that head would have been scheduled and exited in between the 2 writes.
Jan 4, 2024 at 14:18 comment added Kamil Maciorowski @FelixJN A bit cumbersome, but IMO brilliant, at least in case of head -n 1. Thanks!
Jan 4, 2024 at 14:12 comment added FelixJN @KamilMaciorowski uff ... -print -print in find would be POSIX as far as I can see. A bit cumbersome.
Jan 4, 2024 at 13:57 comment added Kamil Maciorowski @FelixJN Piping to head is somewhat "flawed" though.
Jan 4, 2024 at 13:54 comment added terdon Ah yes, good point, @FelixJN, thanks.
Jan 4, 2024 at 13:54 history edited terdon CC BY-SA 4.0
added 22 characters in body
Jan 4, 2024 at 13:37 comment added FelixJN Since -quit is not POSIX, a find ... | head -n 1 might speed up the process for larger sets of files.
Jan 4, 2024 at 13:15 history answered terdon CC BY-SA 4.0