I have a command I am running produces a ton of output, I want to silence the output without writing to a file. I have used the following to send all output to a file:

command > out.txt 2>&1

... but again I don't want any file output:

command > /dev/null 2>&1

I have used command > /dev/null on my CentOS box before, but I can't find a similar thing for windows.

  • I hope you used command > /dev/null on your CentOS. Aug 2, 2010 at 20:43
  • @pipitas whatever i did it worked :D
    – Alec Gorge
    Aug 11, 2010 at 18:19
  • If you indeed used command > /bin/null on CentOS, you have created a common file file named /bin/null on your system. You may say 'It worked!', if you want. This file now contains the stdout and stderr output of your command. Usually, in /bin/ there are only executable files. And usually, only the root user is allowed to create files there. So if that file is there, you did run your command as root user... /bin/null usually doesn't exist -- and /dev/null (which I mentioned) usually is used as the 'black whole' where unwanted output should disappear in... Aug 11, 2010 at 23:13
  • Good point, I hadn't thought of that. However, I am pretty sure it is just my faulty memory because I was on Windows at the time.
    – Alec Gorge
    Aug 18, 2010 at 3:15

2 Answers 2


You want command > nul 2>&1.

  • thanks! that works. I need to wait 12 minutes to accept the answer though (serverfault requirement)!
    – Alec Gorge
    Apr 16, 2010 at 3:22
  • 8
    This only redirects stdout. You also need > nul 2>&1 or 2> nul to kill stderr. Apr 16, 2010 at 14:02
  • Yes I know that, but thanks for mentioning it for others that visit this question!
    – Alec Gorge
    Apr 19, 2010 at 20:52
  • just to add, I was getting permission denied error while using : sudo hostname -f 2> nul whereas following command worked well : sudo hostname -f 2> /dev/null For those who run out into permission issue while using nul
    – Ranvir
    Feb 10, 2015 at 12:34
  • 2
    @AminM nul is Windows' special keyword for a null output (i.e. discard output). On *nix-based systems (like Ranvir is referring to) they instead use the special file /dev/null. The > means "redirect" (and 2> means redirect buffer 2 -- which is the error output)
    – Doktor J
    May 31, 2019 at 17:11

You want command > $null 2>&1

nul only works in command prompt whereas $null works in powershell.

  • 4
    Command Prompt is cmd.exe. '> null' creates a file called 'null' with whatever you're directing into it from cmd.exe and from PowerShell.
    – Mr. Smythe
    Jul 29, 2015 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .