cancel
Showing results for 
Search instead for 
Did you mean: 

/dev/null

 
newunix
Frequent Advisor

/dev/null

what does /dev/null refer to.

cp /dev/null > file name --- nullifies the data and set to zero size file.

whether it sets to zero size or it resides some where else???

what is the use in using /dev/null

2.dd if=/dev/rdsk/cxtydz of=/dev/null bs=1024

what does it refer to ??

3 REPLIES
Steven Schweda
Honored Contributor

Re: /dev/null

Pete Randall
Outstanding Contributor

Re: /dev/null

"cp /dev/null > file name" will null out a file, that is, set it to zero size. The same can be accomplished through file redirection as "> file name".

In your second case dd is being used to test a device for readability, reading in the entire disk without actually seeing the contents. The output file being set to /dev/null simply ignores the output.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: /dev/null

Hi:

The device file '/dev/null' returns nothing as it's name suggests. The shell redirection operator (the '>') says open for output and truncate any file that exists, setting the end-of-file pointer to a zero-offset.

These are all the same:

# cp /dev/null myfile
# cat /dev/null > myfile
# > myfile

That last is a shorthand method.

As for :

# dd if=/dev/rdsk/cxtydz of=/dev/null bs=1024

This says use the '/dev/rdsk/cxtydz' device as the input file ('if'); read it; and write whatever is written to the output file '/dev/null'. Nothing is actually stored on disk; rather the I/O is down-the-drain. The 'bs=1024' says to use a physical read size (block) of 1024 characters.

Normally the above would be 'bs=1024k' for performance. The use of the *raw* device file keeps LVM buffering from needlessly being applied. The command is used to test a disk for readability.

Regards!

...JRF...