.txt
GrepとCurledURLが一致する場合にのみ出力ファイルを保存したい。
私が今持っているものの例:
xargs -d '\n' -I LINE bash -c "curl -s -o - 'LINE/matchme!'| grep -o 'matchme!'" > saveme.txt < domain.txt
これはdomain.txt
ファイルからURLを読み取りますがsaveme.txt
、文字列が一致しない場合でも作成されます+一致するsaveme.txt
場合は、内部にカールしたURLがありません。
期待される出力 saveme.txt
https://example.com/matchme!?random=param-matchme!
https://example2.com/matchme!-マッチミー!
https://example3.com/matchme!-マッチミー!
そのようなスクリプトをどのように作成しますか?
pattern='matchme!'
while IFS= read -r domain; do
url="$domain/matchme!"
curl -s "$url" | grep -q "$pattern" && printf '%s - %s\n' "$url" "$pattern" >> saveme.txt
done < domain.txt
固定文字列を探している場合は、のオプションに追加-F
しgrep
ます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加