NUL is an amusing little file because it cannot be deleted. As described in c:\nul\nul, it is one of the DOS Device files. Because of this, any attempt to delete NUL results in a failure.

The worst part about the whole thing, though, is that when the file is created, people can put data into it. So you can get a gigabyte undeletable file on your hard drive, or more amusingly, some one else's hard drive. (I had someone do this to me at a LAN party recently. Rick, you will die.)

How do you create a little treasure like NUL? Apparently, it's easy to do over file sharing - I'm not clear on the exact process (and I don't think I would post it up here, anyway - if you're not smart enough to figure this out on your own, you shouldn't be doing it), but I think the trick is to create a file, then rename it to NUL. But don't quote me on that.

Curiously, Win2k is affected by this problem, just like everybody else. I know this because I run Win2k. I haven't yet fixed the problem - if anyone feels generous enough to help me out, /msg s_alanet. I'll also post the solution that worked for me in this wu.

In response to Wicker808's comment: The same goes for nul which insinuates, incorrectly, that NUL is a file, which it isn't, and that it stores data, which it doesn't. You should really research your nodes before writing them up.

I've sat on that /msg for some time now, and here is my response:

I realize that NUL is not a file, anymore than /dev/null is a file. HOWEVER, because of the slightly imbalanced implementation of Microsoft NTFS, (and presumably FAT32) file systems, it is possible to, in fact, create a NUL file - one with a name of NUL. And once this file has been created, it is nearly impossible to remove for the reasons outlined above.

If you want to "discuss" this further, I can send you a screenshot of the folder where some friends of mine created a NUL file on my Win2k system at a LAN party.

Your wu is clearly more informative, although I think that a pointer to DOS Device Files is just as effective, and more inducive to a cohesive database.

NUL is a special, reserved file name. NUL is the data sink character device under MS-DOS and related operating systems, including all forms of Windows.

What this is means is that NUL behaves in some ways like a file, but isn't. In particular, data may be written to and read from NUL, but NUL may not be deleted, created, or renamed. Because of the semantics of character devices, all files whose base name is NUL, regardless of extension, are treated identically to NUL.

Because of NUL's status as a data sink, all data written to it will be ignored. Attempts to read data from it will succeed, but no data will be returned.

Some programs are vaguely aware of the special status of NUL and other character devices. For example, attempting to open NUL with Windows Notepad yields the not-terribly-helpful error message "Incorrect function." Attempts to rename a file or directory to NUL using the Windows Explorer will indicate that such a file already exists. Whereas, the MS-DOS Editor will open NUL correctly.

NUL is useful in batch files because program output can be redirected to it. This has the result that the output of that program is discarded. This may be desirable to suppress an expected error message (although only standard output will be redirected, not standard error). For example:

DIR > NUL

NUL is equivelent to /dev/null on Unix systems.

See here for more information on this subject.

Mnemonic for ASCII character 0. In C programming, indicates the end of a string.

Some programmers have trouble remembering the difference between NUL and NULL, the latter being the value of a pointer that points to nothing. For them, this couplet, a parody of Ogden Nash's The Lama, may help:

The one-L NUL ends a string
The two-L NULL points to no thing.

Nul (?), a. [F. See Null, a.] Law

No; not any; as, nul disseizin; nul tort.

 

© Webster 1913.

Log in or register to write something here or to contact authors.