I am trying to search and remove files from a list of servers. I want to find every occurence of this file on each machine and then remove it. If I execute the find command on the remote machine I would like to be able to pipe the output to xargs and remove the file. Does anyone know hat would be the best way to accomplish this?
#!/bin/sh
for filename in big list of filenames to find
do
for server in list of servers to search on
do
ssh you@$server find / -type f -name "$filename" -exec rm {} \;
done
done
(untested)
Assuming only a few filenames here, if you are searching for many different files, it would be more efficient to pass all names to find at once to save many calls to ssh.