Friday, 29 November 2019

curl a url and parse if a key word occurrences

you can curl url | grep "your keyword"  to check if it has your keyword.

curl www.google.com | grep "google"
you can test above command it will give result.

curl www.google.com | grep "googlexxxx"

above will have no result , because it doesn't have your keyword.


curl www.google.com | grep "google" -o

above with -o which will only show matches and occurrence.

you will see a lot of "google"in result.


to count them you can use  | wc -l

so the final command is:

curl www.google.com | grep "google" -o | wc -l



No comments:

Post a comment