logo

How to suppress output in the batch command 📂Programing

How to suppress output in the batch command

Code

output > nul

To omit results written to a file or displayed on the screen, you can redirect the output to a null device.

Windows

In Windows, instead of null, you use nul with a single letter l, or the uppercase NUL1.

@echo off

echo 1 > nul
echo 2
echo 3 > NUL
echo 4
pause

For instance, if you execute an example.bat file written as above, the result would be as follows.

2
4
계속하려면 아무 키나 누르십시오 . . .

Linux

In Linux, instead of nul, you use /dev/null2.

Environment

  • Windows11
  • Linux Mint 21.2 Cinnamon v5.8.4