you can iterate over the response in several ways, e.g.:

  for i in $(locate -i bozo) ; do echo $i ; done

or

  locate -i bozo | while read f ; do echo $f ; done

Be careful about files with whitespace in the filenames. Also, BE VERY
CAREFUL, it's possible to do a lot of damage pretty fast.

On Mon, Apr 18, 2022 at 4:39 PM Michael Barnes <[email protected]> wrote:
>
> I use the locate command often to find files on my machine. How can I act
> on that list?
> For example, I do
> locate -i bozo
> and get a list of all files containing bozo in the name. Now I want to copy
> all those files into a new directory. I've tried various combinations of
> pipe to something, but no joy.
>
> Locate is such an easy command and finds everything I need, while using
> find I need a bunch of parameters I can never remember.
>
> Thanks for any ideas.
>
> Michael

Reply via email to