{"id":2401,"date":"2017-07-15T11:07:44","date_gmt":"2017-07-15T11:07:44","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=2401"},"modified":"2017-07-15T13:55:47","modified_gmt":"2017-07-15T13:55:47","slug":"reading-lines-from-log-files-batch-script","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/reading-lines-from-log-files-batch-script\/","title":{"rendered":"Reading Lines from Log Files &#8211; Batch Script"},"content":{"rendered":"<p>The below batch script helps to read the selected trailing lines from Log File<\/p>\n<pre>\r\n@echo off\r\ncls\r\nsetlocal EnableDelayedExpansion\r\nset \"cmd=findstr \/R \/N \"^^\" C:\\Users\\Mugil\\Desktop\\test.txt | find \/C \":\"\"\r\n\r\nfor \/f %%a in ('!cmd!') do set totalLines=%%a\r\nrem echo \"totalLines-\"%totalLines%\r\n\r\n\r\n@set linesToConsider=4\r\nset \/a lineToStart=\"%totalLines%-%linesToConsider%\" \r\n\r\nrem echo \"lineToStart-\"%lineToStart%\r\n\r\nset content=\r\nfor \/f \"skip=%lineToStart% delims=\" %%i in ('type C:\\Users\\Mugil\\Desktop\\test.txt') do set content=!content! %%i\r\n\r\n\r\n@echo \"content - \"%content%\r\n\r\n\r\nIf NOT \"%content%\"==\"%content:SUCCESS=%\" (\r\n    echo Build Successful\r\n) else (\r\n    echo Build Failed\r\n)\r\n\r\npause\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The below batch script helps to read the selected trailing lines from Log File @echo off cls setlocal EnableDelayedExpansion set &#8220;cmd=findstr \/R \/N &#8220;^^&#8221; C:\\Users\\Mugil\\Desktop\\test.txt | find \/C &#8220;:&#8221;&#8221; for \/f %%a in (&#8216;!cmd!&#8217;) do set totalLines=%%a rem echo &#8220;totalLines-&#8220;%totalLines% @set linesToConsider=4 set \/a lineToStart=&#8221;%totalLines%-%linesToConsider%&#8221; rem echo &#8220;lineToStart-&#8220;%lineToStart% set content= for \/f &#8220;skip=%lineToStart% delims=&#8221; %%i&hellip; <a href=\"https:\/\/codethataint.com\/blog\/reading-lines-from-log-files-batch-script\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[154],"tags":[],"class_list":["post-2401","post","type-post","status-publish","format-standard","hentry","category-misc"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=2401"}],"version-history":[{"count":11,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2401\/revisions"}],"predecessor-version":[{"id":2412,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2401\/revisions\/2412"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=2401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=2401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=2401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}