Giter VIP home page Giter VIP logo

check-url's Introduction

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 [email protected]: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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.