Home > Net >  How to remove a file named '.'?
How to remove a file named '.'?

Time:01-12

Ok so i did something very stupid (copying a file and renaming it '.') since I thought it would just copy it as .uniprot_sprot.fasta.gz.icloud.

cp /path/.uniprot_sprot.fasta.gz.icloud .

and now I don't know how to remove it from current directory as it would be removing '.' itself.

What can I do? This doesn't work. It says: No such file or directory

rm .uniprot_sprot.fasta.gz.icloud

On the other hand:

ls -a 

gives this:

.
..
uniprot_sprot.fasta.gz.icloud

CodePudding user response:

You have not copied a file and renamed it . (at any rate if you're running a sane *nix). Instead you have copied the file to the current directory with the name of the original file. (If you pass a directory to cp as the destination, files will be placed in that directory. . is the current directory, so this is all that has happened.) If you want to remove it you can just rm uniprot_sprot.fasta.gx.iscloud or explicitly rm ./uniprot_sprot.fasta.gx.iscloud. What you have tried to do is to remove a file whose name starts with ., which is a different thing.

Edit: I was unaware when I wrote this, but this is in fact an artefact of the shell, which interprets .. At syscall level you can create a file whose name contains anything except / and \x00 (yep, including \n), assuming your filesystem allows it.
Thus I should have said 'assuming you're running a sane shell', although that is implied in running a sane *nix. See this question on unix.se and its linked dupe.

  •  Tags:  
  • Related