
{"id":16959,"date":"2018-03-04T15:47:10","date_gmt":"2018-03-04T15:47:10","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=16959"},"modified":"2018-03-04T15:47:10","modified_gmt":"2018-03-04T15:47:10","slug":"grep-a-file-but-show-several-surrounding-lines","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2018\/03\/04\/grep-a-file-but-show-several-surrounding-lines\/","title":{"rendered":"grep a file, but show several surrounding lines?"},"content":{"rendered":"<pre>\n$grep -C 1 lambda doowli.py \n    request = urllib2.Request(url)\n    request.get_method = lambda : 'HEAD'\n    try:\n$grep -B 1 -A 0 lambda doowli.py \n    request = urllib2.Request(url)\n    request.get_method = lambda : 'HEAD'\n$grep -B 1 -A 5 lambda doowli.py \n    request = urllib2.Request(url)\n    request.get_method = lambda : 'HEAD'\n    try:\n        response = urllib2.urlopen(request)\n        return True\n    except urllib2.HTTPError:\n        return False\n$grep -C 5  lambda doowli.py \n    print \" Linux Journal -- Year :\", year , \"Month:\", month\n    filename = wget.download(url) \n\ndef file_exists(url):\n    request = urllib2.Request(url)\n    request.get_method = lambda : 'HEAD'\n    try:\n        response = urllib2.urlopen(request)\n        return True\n    except urllib2.HTTPError:\n        return False\n$\n\n<a href=\"https:\/\/beyondgrep.com\/\">https:\/\/beyondgrep.com\/<\/a>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$grep -C 1 lambda doowli.py request = urllib2.Request(url) request.get_method = lambda : &#8216;HEAD&#8217; try: $grep -B 1 -A 0 lambda doowli.py request = urllib2.Request(url) request.get_method = lambda : &#8216;HEAD&#8217; $grep -B 1 -A 5 lambda doowli.py request = urllib2.Request(url) request.get_method = lambda : &#8216;HEAD&#8217; try: response = urllib2.urlopen(request) return True except urllib2.HTTPError: return False $grep &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2018\/03\/04\/grep-a-file-but-show-several-surrounding-lines\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;grep a file, but show several surrounding lines?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83],"tags":[374,863],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16959"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=16959"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16959\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=16959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=16959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=16959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}