{"id":4857,"date":"2014-03-30T16:08:09","date_gmt":"2014-03-30T16:08:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/please-explain-usage-for-for-f-command-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:08:09","modified_gmt":"2014-03-30T16:08:09","slug":"please-explain-usage-for-for-f-command-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/please-explain-usage-for-for-f-command-collection-of-common-programming-errors\/","title":{"rendered":"Please explain usage for for\/f command?-Collection of common programming errors"},"content":{"rendered":"<p>I am using the following to output the java version which I grabbed from another site:<\/p>\n<pre><code>java -version 2&gt; java.txt\nfor \/f \"tokens=3\" %%x in ('find \/i \"java version\" java.txt') \n<\/code><\/pre>\n<p>Output is:<\/p>\n<pre><code>java version \"1.7.0_25\"\nJava(TM) SE Runtime Environment (build 1.7.0_25-b17)\nJava HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)\n<\/code><\/pre>\n<p>Here is the full code:<\/p>\n<pre><code>@echo off\n\nset JavaTemp=C:\\Windows\\Gpologs\n\njava -version\nif \"%ErrorLevel%\"==\"0\" ( goto VersionCheck ) ELSE ( goto Install )\n\n:VersionCheck\njava -version 2&gt; %JavaTemp%\\java.txt\nfor \/f \"tokens=3\" %%x in ('find \/i \"java version\" %JavaTemp%\\java.txt') do (\n  if %%~x==1.7.0_45 goto :eof\n  if %%~x==1.7.0_40 goto Install\n  if %%~x==1.7.0_25 goto Install\n  if %%~x==1.7.0_21 goto Install\n  if %%~x==1.7.0_17 goto Install\n  if %%~x==1.7.0_15 goto Install\n)\n\n:Install\nmsiexec \/i \"\\\\servershare\\sharename\\Java\\jre1.7.0_45_x86\\jre1.7.0_45.msi\" \/qn\nif %ErrorLevel% EQU 0 (\n    &gt;&gt;\"\\\\servershare\\sharename\\jre_1.7.45.x64.csv\" echo \"%computername%\",\"%date%\",\"%Time%\",\"%ErrorLevel%\",\"Java Runtime 1.7.0_45x86 Installed\"\n    &gt;&gt;\"%windir%\\GpoLogs\\jre_1.7.45.x64.txt\" echo \"Java Runtime 1.7.0_45x86 Installed\"\n) else (\n    &gt;&gt;\"\\\\servershare\\sharename\\JavaInstallErrors.csv\" echo \"%computername%\",\"%date%\",\"%Time%\",\"%ErrorLevel%\",\"Error trying to install Java 1.7_45x86\"\n)\n<\/code><\/pre>\n<p>I just need to know why the tokens is 3? please explain as soon as I get my head around it, it will make a lot more sense \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am using the following to output the java version which I grabbed from another site: java -version 2&gt; java.txt for \/f &#8220;tokens=3&#8221; %%x in (&#8216;find \/i &#8220;java version&#8221; java.txt&#8217;) Output is: java version &#8220;1.7.0_25&#8221; Java(TM) SE Runtime Environment (build 1.7.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) Here is the full code: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4857","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4857"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4857\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}