So yes, as is stated many times elsewhere, a filename can contain nearly any character. But it needs to be said that a filename is not a file. It does carry some weight as a file attribute in that you typically need a filename to open a file, but a file's name only points to the actual file. It is a link, stored in the directory that has recorded it, alongside the inode number - which is a much closer approximation to an actual file.
So, you know, call it whatever you want. The kernel doesn't care - all file references it will handle will deal with real inode numbers anyway. The filename is a thing for human consumption - if you wanna make it a crazy thing, well, it's your filesystem. Here, I'll do some crazy stuff:
First I'll create 20 files, and name them with nothing but spaces, each filename containing one more space than the last:
until [ $((i=$i+1)) -gt 20 ]
do v=$v' ' && touch ./"$v"
done
This is kinda funny. Look at my ls
:
ls -d ./*
./ ./ ./ ./ ./
./ ./ ./ ./ ./
./ ./ ./ ./ ./
./ ./ ./ ./ ./
Now I'm going to mirror this directory:
set -- * ; mkdir ../mirror
ls -i1qdU -- "$@" |
sh -c 'while read inum na
do ln -T "$1" ../mirror/$inum
shift ; done' -- "$@"
ls -d ../mirror/*
Here are ../mirror/
's contents:
../mirror/423759 ../mirror/423764 ../mirror/423769 ../mirror/423774
../mirror/423760 ../mirror/423765 ../mirror/423770 ../mirror/423775
../mirror/423761 ../mirror/423766 ../mirror/423771 ../mirror/423776
../mirror/423762 ../mirror/423767 ../mirror/423772 ../mirror/423777
../mirror/423763 ../mirror/423768 ../mirror/423773 ../mirror/423778
Ok, but maybe you're asking - but what good is that? How can you tell which is which? How can you even be sure you linked the right inode number to the right filename?
Well...
echo "heyhey" >>./' '
tgt=$(ls -id ./' ')
cat ../mirror/${tgt%% .*} \
$(ls -1td ../mirror/* | head -n1)
OUTPUT
heyhey
heyhey
See, both the inode number contained in ../mirror/"${tgt%% .*}"
and that referenced by ./' '
refer to the same file. They describe the same file. They name it, but nothing more. There is no mystery, really, just some inconvenience you might make for yourself, but which will ultimately have little to no effect on the operation of your unix filesystem in the end.
-rf ~
(usetouch -- "-rf ~"
), but I wouldn't recommend it./
separator). Using all 254 remaining bytes opens the door to all manners of unspeakable eldritch "names". Obviously this is insane, but not everyone agrees on what "sane" is, and different characters will break different tools. The intersection of everyone's sanity is quite small.