How to remove file with mv command?

mv other-file file-to-be-deleted
mv file-to-be-deleted other-file

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.

Tags:

Solaris

Mv

Rm

Files