dev null

Thilo Six T.Six at gmx.de
Mon Mar 13 23:26:17 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

lordSauron schrieb am 13.03.2006 23:49:
> On 3/13/06, Thilo Six <T.Six at gmx.de> wrote:
> 
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: RIPEMD160
>>
>>lordSauron schrieb am 13.03.2006 20:49:
>>
>>>Just a little question from someone who's still really new to Unix in general...
>>>
>>>What is /dev/null?  I've heard it mentioned before, but I don't know
>>>what it's function is.  Is it a mechanism that deletes things?  That
>>>is my first guess, but I could be off the mark.
>>
>>Yes you are right. Anything that is copied or moved to /dev/null disapears.
>>This works with files or with output on comand line.
>>
>>try this:
>>ls /etc/
>>
>>and then this:
>>ls /etc/ > /dev/null
> 
> 
> Will this murder my /etc directory, by chance?

No.
The example above will "murder" the uotput from the ls command.
This is very commonly used in scripts.

e.g. here is a snipped from /usr/bin/startkde, which is the script, that
starts kde:
- --------------------------------->
# Check if a KDE session already is running
if kcheckrunning >/dev/null 2>&1; then
        echo "KDE seems to be already running on this display."
<---------------------------------

...if kcheckrunning >/dev/null 2>&1....
                        ^^^

What is done here is output redirection. This is used to supress
possibly error messages from being displayed.


> So... /dev/null... that works for output?  Is that how things like
> aptitude can have their fancy contant redraw of the screen all the
> time?  I've been wondering about things like that, because I want to
> make nifty things like that, too.

/dev/null is AFAIK a virtual device, which means it has no hardware.
An other device with does have hardware is /dev/input/mice

try this:
sudo cat /dev/input/mice

and move your mouse. Your display will show you all the data that your
mouse is sending to your computer.

In linx everything is a file. Everything can be cat´ed, cp´ed and so on.
Also the data from your mouse to your computer through /dev/input/mice
(which is the file thats represend your mouse).

If you are more interrested in this have a look here:

http://en.wikipedia.org/wiki//dev/null

and google for "output" and/or "input redirection"

bye Thilo
- --
i am on Ubuntu 2.6 KDE
- - some friend of mine
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEFf+XzeyTbiZA74IRA0NsAJ9WxuHkHRPCihjfl0lEsICqi1F/PgCfUNCQ
uMrAu4g3UN/jm5g4QdLxQNg=
=OsZQ
-----END PGP SIGNATURE-----





More information about the kubuntu-users mailing list