Artificial intelligent assistant

Curl / Grep save output to file with URL only if match I want to save output `.txt` file only if it matches Grep with Curled URL. example what I have right now: xargs -d '\n' -I LINE bash -c "curl -s -o - 'LINE/matchme!'| grep -o 'matchme!'" > saveme.txt < domain.txt which reads URLs from `domain.txt` file, however it does create `saveme.txt` even when string is not matched + without curled URL inside `saveme.txt` if it does match. Expected output in `saveme.txt` < \- matchme! < - matchme! < - matchme! How would I construct such script?

pattern='matchme!'
while IFS= read -r domain; do
url="$domain/matchme!"
curl -s "$url" | grep -q "$pattern" && printf '%s - %s\
' "$url" "$pattern" >> saveme.txt
done < domain.txt


Add `-F` to `grep`'s options if you're looking for a fixed string.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 5b4387771ccfd4d7b1a708ce43ed1415