On Tue, Jan 14, 2025 at 04:40:38 -0500, Karl Vogel wrote: > for file in $(find . -maxdepth 1 -name '*.sqlite' -print); do
Just be aware that this is *not* safe in general. It will fail if any of the pathnames contain whitespace. It may work fine on your Firefox directory, but other applications may not be so accomodating. hobbit:~$ find .cache/google-chrome/ -name '* *' .cache/google-chrome/Default/Storage/ext/nmmhkkegccagdldgiimedpiccmgmieda/def/Code Cache .cache/google-chrome/Default/Code Cache In your specific case, with -maxdepth 1, you don't really need to use find. You could just use: for file in *.sqlite ; do ... Unfortunately, if you *do* need find, all of the safe ways to iterate over its results are far uglier. Probably the least ugly is this one: find . -name '*.sqlite' -print0 | while IFS= read -r -d '' file ; do ... This runs the while loop in a subshell, meaning any variable changes that you make inside the loop won't persist in your main shell. That may not be a problem, depending on what you do in the loop. <https://mywiki.wooledge.org/BashPitfalls#pf1> has a more comprehensive discussion.