what is the difference between 1> and 2>

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

what is the difference between 1> and 2>

#1 Post by nnnmmm » 31 Mar 2024 10:46

Code: Select all

SET A1=%LocalAppData%Low
2>nul del /q "%A1%\MCC\Saved\Logs\cef3.log"
2>nul RMDIR /S /Q "%A1%\MCC\Temporary"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Crashes"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\webcache"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Config\CrashReportClient"

SET A1=%LocalAppData%Low
1>nul del /q "%A1%\MCC\Saved\Logs\cef3.log"
1>nul RMDIR /S /Q "%A1%\MCC\Temporary"
1>nul RMDIR /S /Q "%A1%\MCC\Saved\Crashes"
1>nul RMDIR /S /Q "%A1%\MCC\Saved\webcache"
1>nul RMDIR /S /Q "%A1%\MCC\Saved\Config\CrashReportClient"


what is the difference between 1>  and 2> , i didnt quite get this example i wrote long ago
(ECHO AAA) 1>"M:\111.TXT"
(ECHO BBB) 1>>"M:\111.TXT"
::(ECHO ccc) 2>"M:\111.TXT"
(ECHO DDD) 2>>"M:\111.TXT"
PAUSE
i forgot the difference between 1> and 2>
i want the errors not to be displayed when del or RMDIR doesnt find files
which is the correct one 1> or 2>?
few words would help


nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: what is the difference between 1> and 2>

#3 Post by nnnmmm » 31 Mar 2024 17:33

Code: Select all

this was the 1st time i tried, and redirection webpage was this way.
SET A1=%LocalAppData%Low
del /q "%A1%\MCC\Saved\Logs\cef3.log" 2>nul
RMDIR /S /Q "%A1%\MCC\Temporary" 2>nul
RMDIR /S /Q "%A1%\MCC\Saved\Crashes" 2>nul
RMDIR /S /Q "%A1%\MCC\Saved\webcache" 2>nul
RMDIR /S /Q "%A1%\MCC\Saved\Config\CrashReportClient" 2>nul


but i have seen people do something like this way and it was much more readable in one glimpse so i mimicked it. is there a way to do this?
SET A1=%LocalAppData%Low
2>nul del /q "%A1%\MCC\Saved\Logs\cef3.log"
2>nul RMDIR /S /Q "%A1%\MCC\Temporary"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Crashes"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\webcache"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Config\CrashReportClient"

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: what is the difference between 1> and 2>

#4 Post by ShadowThief » 01 Apr 2024 16:31

2 is for errors (STDERR), 1 is for everything else (STDOUT)

It doesn't matter if you put it at the front or the back of the command you're using it on, although there are a few edge cases where putting it at the front is better.

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: what is the difference between 1> and 2>

#5 Post by nnnmmm » 04 Apr 2024 07:33

>It doesn't matter if you put it at the front or the back

thanks, i will go back to this way
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Crashes"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\webcache"
2>nul RMDIR /S /Q "%A1%\MCC\Saved\Config\CrashReportClient"

Post Reply