How to LINK a file to /dev/null?

Hi!

I want link a file to /dev/null.

I did:

sudo ln -s /dev/null /path-to/file name

Error message:

ln: failed to create symbolic link '/path-to/file name': File exists

Maybe it is so right?

sudo ln -s /path-to/file name /dev/null

Please help, thanks!

the file (target) should NOT exist, then ln -s /dev/null mat

lrwxrwxrwx 1 user user 9 Sep 24 12:10 mat -> /dev/null

$ file mat
mat: symbolic link to /dev/null

In other words, delete the file /path-to/filename first, then create a symbolic link with sudo ln -s /dev/null /path-to/filename.

Also note that a file name with a space in it should be quoted:

sudo ln -s /dev/null '/path-to/file name'

I hope that helps.

thanks @ gordon. :slight_smile: