Questions tagged [dev-null]

On Unix-like systems, /dev/null is a device file that discards all data written to it but reports that the write operation succeeded.

On Unix-like systems, /dev/null is a device file that discards all data written to it but reports that the write operation succeeded. It is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams.

69 questions
78
votes
3 answers

How can I redirect all output to /dev/null?

I want to run a program (google-chrome) in the background, but prevent it from outputting any messages to the terminal. I tried doing this: google-chrome 2>&1 1>/dev/null & However, the terminal still fills up without messages…
Benubird
  • 18,551
  • 27
  • 90
  • 141
63
votes
6 answers

Will printf still have a cost even if I redirect output to /dev/null?

We have a daemon that contains a lot of print messages. Since we are working on an embedded device with a weak CPU and other constraint hardware, we want to minimize any kinds of costs (IO, CPU, etc..) of printf messages in our final version. (Users…
Michael
  • 1,313
  • 11
  • 25
16
votes
3 answers

Can I get a faster output pipe than /dev/null?

I am running a huge task [automated translation scripted with perl + database etc.] to run for about 2 weeks non-stop. While thinking how to speed it up I saw that the translator outputs everything (all translated sentences, all info on the way) to…
naugtur
  • 16,827
  • 5
  • 70
  • 113
13
votes
3 answers

What is the DOS equivalent of 1>/dev/null?

I want to suppress the output of my script running under DOS, similar to the following under a *nix environment: $ command 1>/dev/null How can I do this?
Zaid
  • 36,680
  • 16
  • 86
  • 155
10
votes
2 answers

What is Android 11's equivalent of '/dev/null'

Android 11 introduced multiple changes to file storage and access. Apparently one of them is that one can no longer target output to '/dev/null' (my scenario is actually exactly explained in this old question). Although the cited question solved the…
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135
8
votes
1 answer

Java: FileOutputStream("NUL:") not working after Java upgrade

On Windows, NUL is the null output device similar to /dev/null on Linux. With Oracle Java 8 Update 331, trying to get a new FileOutputStream("NUL:") throws an exception. Previously (Java 8u321) it worked fine. The problem seems to be the colon: new…
nodots
  • 1,450
  • 11
  • 19
7
votes
2 answers

Is there a null device in Matlab?

I'm trying to find an easy way to turn logging to a text file on and off much like the example seen here in Python. Their solution was to use a valid file name where logging is desired and to use the null device 'dev/null' otherwise. They're using…
jxramos
  • 7,356
  • 6
  • 57
  • 105
7
votes
3 answers

redirect bash output and error for all commands

How to redirect all commands executed on the bash to /dev/null ? It's obvious that for a command we have to do: command > /dev/null 2>&1 How about all commands that will be executed further on ?
TheForbidden
  • 1,533
  • 4
  • 22
  • 30
6
votes
3 answers

The "opposite" of &> /dev/null

I use the following script to compare to folders: if diff "/home/folder1/" "/home/folder2/" &> /dev/null ; then echo "Files in the two folders are the same" else echo "Files in the two folders are NOT the same" fi Is there a brief way…
Paolo
  • 2,161
  • 5
  • 25
  • 32
5
votes
4 answers

Is /dev/null always openable?

I want to suppress certain fprintf calls by redirecting the destination FILE to /dev/null. But can I be sure, that fopen("/dev/null", "w"); NEVER returns NULL. In other words, is it everytime possible to open this "file"? If so, I could use this…
Michael Gierer
  • 401
  • 2
  • 6
  • 15
5
votes
1 answer

Python suppress shell output

My Python script is calling a shell command via os.system as: os.system('sudo ifdown wlan0 &> /dev/null') If I run this command without Python, the output is suppressed, in Python, however, it still prints the output. What am I doing wrong?
user5740843
  • 1,540
  • 5
  • 22
  • 42
5
votes
1 answer

Cannot pull because there are uncommitted changes using VS2015/Git

Imagine the following scenario: Manager has created a team project and decided to use (latest) git as VCS for the project. Developer team will be working using (latest) VS2015 (Enterprise) IDE. Manager has created a new (origin) branch called…
OmegaExtern
  • 856
  • 2
  • 7
  • 15
5
votes
2 answers

os.stat on Windows "nul" file

Why can't I call os.stat on the special Windows file nul? >>> import os >>> os.stat('nul') Traceback (most recent call last): File "", line 1, in WindowsError: [Error 87] The parameter is incorrect: 'nul' I can open it: >>> f =…
jterrace
  • 64,866
  • 22
  • 157
  • 202
4
votes
3 answers

C code to check if command line is redirected to /dev/null

I'm writing a C program that outputs to stdout and errors to stderr. The program takes a command such as: ./myprogram function_to_run file_to_read My program can either output to stdout or be directed to output a file, but it must not be redirected…
LKT
  • 311
  • 1
  • 7
  • 17
3
votes
1 answer

End of record when writing to /dev/null

In our numerical software I encountered a strange bug after upgrading our cluster. It namely is: At line 501 of file /home/weser/code/neci/src/fcimc_helper.F90 (unit = 6, file = '/dev/null') Fortran runtime error: End of record In this line there…
mcocdawc
  • 1,748
  • 1
  • 12
  • 21
1
2 3 4 5