I accidentally used "touch .." , is there a way to safely delete this document?
touch
just creates a new empty file if a previously extant file is not specified. If specified it will update the last modified date.
As you created it on your desktop, I'm sure it would be simplest to just grab it and drag it to the trash… saves making any further errors ;)
It will cause no issues at all.
rm
has consequences for the unwary that a simple drag & drop doesn't.
-
.
means the current directory -
..
means the directory above the current location
If you're not sure where you are, rm ..
could be somewhat chaotic, as it will delete (potentially all) files from the next directory up.
Do not delete it! In unixish filesystems (including macOS), ..
is a link to the parent directory. So if you were in the directory /Users/Serax/Desktop
and you ran touch ..
, that's equivalent to touch /Users/Serax
, which just marks your home directory as being modified.
Similarly, when you're in /Users/Serax/Desktop
, trying to delete ..
is equivalent to trying to delete your home directory. If you succeeded, you'd lose all your files. You do not want to do this.
Running that touch
command will not have damaged anything, so there's nothing that needs to be fixed, deleted, or cleaned up. Just go about your business.
BTW, do you have a good backup? If not, I'd strongly recommend you make one. Because accidents happen, and sometimes you delete your entire home directory by mistake.