help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use `find' "-printf" predicate inside bash script


From: JB
Subject: Re: Use `find' "-printf" predicate inside bash script
Date: Wed, 20 Oct 2021 21:07:20 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Tuesday, October 19th, 2021 at 2:19 PM, Andreas Kusalananda Kähäri 
<andreas.kahari@abc.se> wrote:

> > Had tried that already but it failed because $args_find[@] wasn't quoted. 
> > Didn't test quoting because
> > $args_find[*] broke `find', so I figured double-quoting $args_find[@] would 
> > as well. This works:
> >
> > find /tmp/ "$args_find[@]"
>
> Note that this is not the correct syntax for expanding the array
> args_find. Also, your message reads as if the complete solution was to
> use "$args_find[@]" whereas using the array correctly is only half the
> answer. The other half is to actually create the array.
>
> args_find=( -type f -mtime -1 -delete -printf 'deleted file: %f\n' )
> find /tmp "${args_find[@]}"

Yes, I know. I mistyped the final form in my reply, and didn't think it needed 
mentioning that I transformed the
variable into an array. It was all implicit in the "This works:" comment I made 
after testing it.

But thank you for pointing it out for anyone else reading this on the list.

Sent with ProtonMail Secure Email.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]