Overview
Incorrect specification of an argument in a commandline tool (details below) has led to the creation of a file literally named “.”. I have already found out that directly trying to delete in Finder will trigger deletion of all content in the containing folder (fortunately this is a temporary folder), but still not the “.” file itself. Moreover, no folders containing this file can be successfully deleted, neither with Finder nor from bash/zsh shell.
How can one actually delete (or rename) such a file?
Attempts to delete from zsh
For example:
mytmp % ls -hal
total 65
drwx------ 1 user staff 16K Aug 21 11:20 .
-rwx------ 1 user staff 0B Aug 21 09:51 .
drwx------ 1 user staff 16K Aug 16 16:30 ..
mytmp % ls -aB
. . ..
mytmp % rm -rf '.'
rm: "." and ".." may not be removed
mytmp % cd ..
scratch % rm -rf mytmp
rm: mytmp: Permission denied
scratch % sudo rm -rf mytmp
rm: mytmp: Permission denied
I’ve also tried variations without -r
, since really it is the non-directory version that is to be deleted.
I additionally tried the suggestion of @bmike to use the inode. While we can identify the inode, the deletion does not appear to work:
scratch % ls -ila mytmp
total 65
8056451580272514705 drwx------ 1 user staff 16384 Aug 21 11:20 .
8652239633868421122 -rwx------ 1 user staff 0 Aug 21 09:51 .
2 drwx------ 1 user staff 16384 Aug 21 11:43 ..
scratch % find mytmp -inum 8652239633868421122 -delete
## no change
scratch % ls -ila mytmp
total 65
8056451580272514705 drwx------ 1 user staff 16384 Aug 21 11:20 .
8652239633868421122 -rwx------ 1 user staff 0 Aug 21 09:51 .
2 drwx------ 1 user staff 16384 Aug 21 11:43 ..
Is it really named “.”?
@nohillside proposed to delimit the listings with x
and y
to see if it really is named “.”. From bash
:
bash-3.2$ for i in .*; do echo x${i}y; done
x.y
x.y
x..y
Appears so.
@fd0 suggested printing non-printing characters with cat -vet
. From bash
:
bash-3.2$ ls -1a | cat -vet
.$
.$
..$
Again, seems identically named.
@nohillside Suggested running a Python server from the directory and display its directory listing:
Additional Background
The folder is on a network Volume, format SMB (OS X).
The tool that resulted in this was haplogrep
, a Java-based CLI. One can install it through Conda via
conda install -c conda-forge -c bioconda haplogrep
The subcommand used was haplogrep classify
, which has the following options:
mytmp % haplogrep classify
mtDNA Haplogroup Classifiction v2.4.0
https://github.com/seppinho/haplogrep-cmd
(c) Sebastian Schönherr, Hansi Weissensteiner, Lukas Forer, Dominic Pacher
[email protected]
[classify]
Missing required options: '--input=<in>', '--output=<out>', '--format=<format>'
Usage: haplogrep classify [--chip] [--extend-report] [--rsrs]
[--skip-alignment-rules] [--write-fasta]
[--write-fasta-msa] --format=<format>
[--hetLevel=<hetLevel>] [--hits=<hits>] --in=<in>
[--lineage=<lineage>] [--metric=<metric>] --out=<out>
[--phylotree=<tree>]
--chip VCF data from a genotype chip
Default: false
--extend-report Add flag for a extended final output
Default: false
--format=<format> Specify input file format: vcf, fasta or hsd
--hetLevel=<hetLevel> Add heteroplasmies with a level > X from the VCF
file to the profile (default: 0.9)
--hits=<hits> Calculate best n hits
--in, --input=<in> Input VCF, fasta or hsd file
--lineage=<lineage> Export lineage information as dot file, \n0=no
tree, 1=with SNPs, 2=only structure, no SNPs
--metric=<metric> Specifiy other metrics (hamming or jaccard) than
default (kulczynski)
--out, --output=<out> Output file location
--phylotree=<tree> Specify phylotree version
--rsrs Use RSRS Version
Default: false
--skip-alignment-rules
Skip mtDNA nomenclature fixes based on rules for
FASTA import
Default: false
--write-fasta Write results in fasta format
Default: false
--write-fasta-msa Write multiple sequence alignment (_MSA.fasta)
Default: false
I misinterpreted the “Output file location” description of the --out
argument as asking for a path, leading me to use --out .
and thus resulting in creating a file named “.”.
Renaming
The file itself cannot be renamed in Finder or with mv
, however, the containing folder can be renamed.