{"id":445,"date":"2018-01-25T14:00:23","date_gmt":"2018-01-25T14:00:23","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=445"},"modified":"2018-01-25T14:00:23","modified_gmt":"2018-01-25T14:00:23","slug":"programming-how-to-check-if-an-ip-is-available-or-not-in-bash","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/programming-how-to-check-if-an-ip-is-available-or-not-in-bash.html","title":{"rendered":"Programming: How To Check if an IP is Available or Not in Bash"},"content":{"rendered":"<h4>How To Check if an IP is Available or Not in Bash<\/h4>\n<p>A quick trick I use is &#8216;ping&#8217; command. PING will return 0 on success and 1 or above on failure while using it with -c 1 (Means only one ICMP packet). That makes it useful to use with a if condition shell code as following:<\/p>\n<p><code>if ping -c 1 -w 5 192.168.2.1 &gt;\/dev\/null<br \/>\nthen<br \/>\necho \"IP Available\"<br \/>\nelse<br \/>\necho \"IP Not Available\"<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How To Check if an IP is Available or Not in Bash A quick trick I use is &#8216;ping&#8217; command. PING will return 0 on success and 1 or above on failure while using it with -c 1 (Means only one ICMP packet). That makes it useful to use with a if condition shell code &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/programming-how-to-check-if-an-ip-is-available-or-not-in-bash.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Programming: How To Check if an IP is Available or Not in Bash&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[282,12,271],"tags":[283,287,276],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/445"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":446,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/446"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}