1
   

>nul in batch scripting

 
 
Reply Wed 3 Dec, 2003 02:47 pm
I've seen this, used this, but haven't found any explanation for this.

Why do we need the >nul in batch scripting, IE:
dir|find "Volume in drive %DRIVE% is MI_">nul

And what does this snippet of code accomplish?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 5,748 • Replies: 6
No top replies

 
yeahman
 
  1  
Reply Wed 3 Dec, 2003 03:05 pm
it prevents any output message.
0 Replies
 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 03:34 pm
It's just like > /dev/null in other languages. Surpresses an error message etc.
0 Replies
 
music2myear
 
  1  
Reply Wed 3 Dec, 2003 04:51 pm
thx, so feasibly I could run it at the end of every command instead of using the @Echo off at the beginning if I desired greater flexibility and wasn't worried about size? or am I a little eensy-weensy bit off?
0 Replies
 
yeahman
 
  1  
Reply Wed 3 Dec, 2003 06:20 pm
@echo off supresses the script from being displayed. it still displays any output generated by the script. >nul displays the script but supresses any output generated.
0 Replies
 
Monger
 
  1  
Reply Wed 3 Dec, 2003 07:16 pm
music2myear, here's an example of ye110man's good explanation. . . say the following command was being processed in a batch file:
Code:copy a:\*.* b:\*.*

@echo off would prevent "C:\>copy a:\*.* b:\*.*" from being shown, while >nul would suppress its output (which would be either "X files copied successfully" or an error message).


Edit: typo fixed
0 Replies
 
Monger
 
  1  
Reply Wed 3 Dec, 2003 07:25 pm
music2myear wrote:
thx, so feasibly I could run it at the end of every command instead of using the @Echo off at the beginning if I desired greater flexibility and wasn't worried about size?

If you wanted greater control over the ECHO state, what you need isn't ">nul" but "@".

Regardless of the ECHO state, a batch file line that begins with the [@] character will not be displayed.
0 Replies
 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » >nul in batch scripting
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/04/2024 at 01:58:41