I started to study Solaris in my university. Teacher told me to remove a file with mv
command.
I tried to move a file to /dev/null. But that did not work.
How can I remove file with mv
command?
Here is a (dumb) way to remove your file using mv
:
mv file /tmp
init 6
Of course, rm file
is significantly faster, more efficient and reliable, and less intrusive.
rm
unlinks your file, and it'll be really hard to get it back.
Perhaps your teacher means something like:
mv myfile ~/.trash
(After first having done a mkdir ~/.trash
of course )
This does a “move to trash” like you see on Windows and OSX (and some linux desktops), instead of unlinking the file.
Later, you can then cd ~/.trash
and find your file.
Something is removed if it is no longer there where it used to be, that doesn't necessarily imply that it no longer exists or is inaccessible via other means. Both when using computers and in real life we often remove things by first moving them to the trash, from where it still can be retrieved.
Literally a simple
mv filename ../some_other_directory_next_to_the_one_you_re_in/filename
already removes the file (from your current directory).
If you need to remove the file from your computer using mv
you can, if networked, use mv
to move the file to a different computer and assign it a new name (mv filename /mountpoint/otherfilename
gives you a different file otherfilename
on the remote system which happens to have the same content as your original filename
)
mv
andrm
? Moving a file to/dev/null
can only damage/dev/null
, it won't delete the file.mv
command