I am using find in a while loop. it takes a list of ips in ip.txt, searches for the ip in a directory of files and then writes the name of the file that each IP was found in to a file called results.res
I want find to stop and move onto the next ip after each succesful find.
My current script is:
while read ip; do find . -type f -maxdepth 1 -not -name ips.txt -not -name results.res -print0 | xargs -0 grep "$ip" >> results.res done < ips.txt
I have researched other answers on the website and found that using
-print -quit -print | head -n 1
stops find after the first succesful find, however because i'm using a while loop this does not work, can anybody suggest a working solution?