[Solved] What does the ^ do in this string: /b /a:-d /o:-d 2^NUL ?

Score
0
Vote Up
February 5, 2012 at 15:19:12 Pacific
Specs: Windows 7

What does the "^" do in this string: /b /a:-d /o:-d 2^>NUL ?

Jump to Best Answer ↓   Report •


#1
Vote Down
Score
0
Vote Up
February 5, 2012 at 15:22:49 Pacific

Actually, the entire string, to be more fair is:

for /f "skip=10 delims=" %%a in ('dir *.tib /b /a:-d /o:-d 2^>NUL') do del /q "%%a"

And, a more complete question would be what does "2^" mean in that snippet?

Thanks.


Reply ↓  Report •

#2
Vote Down
Score
0
Vote Up
February 6, 2012 at 06:12:13 Pacific

Best Answer

The ^ (caret) symbol is mandatory when you code a special character like the > redirector as part of a command used as FOR /F clause. 2>nul (2^>nul in the reported case) redirects stderr (2) to the nul device so erasing any error message to the screen (in the same way 1>nul suppresses any result line to the screen).

This to force the DIR command to run silently even if no files are found since the command output is piped to DEL by the FOR statement but the error messages are still directed to screen since stderr is different from stdout.

Anyway this has nothing to do with DOS that doesn't exist in Win 7 as NT kernel based. This is NT batch and what you believe to be the DOS command prompt actually is the NT system console.


Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« client server multi-threa... [Solved] I SIMPLY want to download... »