{"id":31153,"date":"2006-05-18T10:00:07","date_gmt":"2006-05-18T10:00:07","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/05\/18\/the-redirection-operator-can-occur-in-the-middle-of-the-command-line\/"},"modified":"2006-05-18T10:00:07","modified_gmt":"2006-05-18T10:00:07","slug":"the-redirection-operator-can-occur-in-the-middle-of-the-command-line","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060518-07\/?p=31153","title":{"rendered":"The redirection operator can occur in the middle of the command line"},"content":{"rendered":"<p>\nAlthough the redirection operator traditionally appears at the end\nof a command line, there is no requirement that it do so.\nAll of these commands are equivalent:\n<\/p>\n<pre>\necho A B&gt;C\necho A&gt;C B\necho&gt;C A B\n&gt;C echo A B\n<\/pre>\n<p>\nAll of them echo &#8220;A B&#8221; to the file &#8220;C&#8221;.\n<\/p>\n<p>\nYou can use this trick to avoid\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/05\/17\/599916.aspx\">\nthe redirection problem we discussed last time<\/a>.\nWe saw that writing\n<\/p>\n<pre>\nset message=Meet at 2\necho %message%&gt;schedule\n<\/pre>\n<p>\ninadvertently interprets the &#8220;2&#8221; as part of the redirection operator.\nOne solution was to insert a space:\n<\/p>\n<pre>\necho %message% &gt;schedule\n<\/pre>\n<p>\nbut this assumes that the space won&#8217;t cause a problem.\nIf you&#8217;re in a case where that space will indeed cause a problem,\nyou can use the trick above to move the redirection operator\nto a location where it won&#8217;t cause any trouble:\n<\/p>\n<pre>\n&gt;schedule echo %message%\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Although the redirection operator traditionally appears at the end of a command line, there is no requirement that it do so. All of these commands are equivalent: echo A B&gt;C echo A&gt;C B echo&gt;C A B &gt;C echo A B All of them echo &#8220;A B&#8221; to the file &#8220;C&#8221;. You can use this trick [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[104],"class_list":["post-31153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>Although the redirection operator traditionally appears at the end of a command line, there is no requirement that it do so. All of these commands are equivalent: echo A B&gt;C echo A&gt;C B echo&gt;C A B &gt;C echo A B All of them echo &#8220;A B&#8221; to the file &#8220;C&#8221;. You can use this trick [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=31153"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31153\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=31153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=31153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=31153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}