i-am-naveen-m-j / check-url

Small script to check if URL is valid or not.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URL Checker πŸ‘€

A simple bash script to check if a URL is valid or not.

How to install πŸ”Ό

You don't have to install anything, this is just a plain bash script. However you are able to get it using git clone:

foo@bar:~$ git clone git@github.com:herczogzoltan/url-checker.git

How to use

The script echoes the error message and the url checked into the standard output. Also when an error occurs, it saves the URL into a file called invalid_urls.txt.

Check single URL

βœ… OK responses (HTTP status code 200-299):

foo@bar:~$ ./check-url.sh https://github.com
Checking https://github.com ..
βœ… OK status code: $status_code for domain $URL

⚠️ WARNING responses (HTTP status code 300-399):

foo@bar:~$ ./check-url.sh http://google.com
Checking http://google.com ..
⚠️ Warning - Redirection - code: 301 for URL: http://google.com

β›” Error responses:

foo@bar:~$ ./check-url.sh https://github.com/i-am-a-404
Checking https://github.com/i-am-a-404 ..
β›” Error status code: 404 for URL: https://github.com/i-am-a-404

Check multiple URLs from file source

foo@bar:~$ cat example-urls.txt | xargs -n 1 ./check-url.sh
Checking https://google.com ..
⚠️ Warning - Redirection - code: 301 for URL: https://google.com
Checking https://github.com ..
βœ… OK status code: 200 for domain https://github.com
Checking https://invalidurl-asdf1234.com ..
β›” Error status code: 000 for URL: https://invalidurl-asdf1234.com

Run in parallel mode using lines of files

foo@bar:~$ cat example-urls.txt | xargs -n 1 -P 4 ./check-url.sh
Checking https://google.com ..
Checking https://github.com ..
Checking https://invalidurl-asdf1234.com ..
β›” Error status code: 000 for URL: https://invalidurl-asdf1234.com
⚠️ Warning - Redirection - code: 301 for URL: https://google.com
βœ… OK status code: 200 for domain https://github.com

Modify -P flag in the above example according to your needs and resources

About

Small script to check if URL is valid or not.

License:GNU General Public License v3.0


Languages

Language:Shell 100.0%