I started to study Solaris in my university. Teacher told me to remove a file with
I tried to move a file to /dev/null. But that did not work.
How can I remove file with
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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 file /tmp init 6
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