.bashrc
as a string contains only printable characters from the ASCII set. If there was any common unprintable character, then ls -a
would show it to you one way or another (I mean ls
in Ubuntu, in general this depends on implementation), so you would already know.
But there are Unicode non-ASCII characters that look like ASCII (or may look, depending on the font used). E.g. these three strings are pairwise different:
.bashrc
.bаshrc
.bashrс
Ubuntu should have no problem creating files with these names on any modern Linux filesystem. You can test it (hint: in an empty directory, so it's easy to rm -r
it as a whole later):
touch .bashrc .bаshrc .bashrс; ls -a
The first one is what you would expect. The second one uses this letter instead of ASCII a
. The third one uses this letter instead of ASCII c
. It's quite obvious one can easily create yet another impostor – with these two non-ASCII letters.
Then there are "uncommon" unprintable characters ls
would not show to you. This command (in Bash)
touch $'.bas\xE2\x80\x8Ehrc'
creates yet another impostor (with left-to-right mark). For this file all characters you see in the output of ls -a
are ASCII characters. You need like ls -a | xxd
to spot what hides inside the name.
So this is one possible answer to "what is going on here?"
It's virtually impossible your first command created the impostor file, unless
- you had copied the command from somewhere,
- or your keyboard settings are weird (but then the string
.bashrc
you typed here on Super User would probably be affected; I have checked it's ASCII).
I suspect the extra file was already there, unnoticed. Maybe because of
- a prank,
- or some rogue software,
- or some other not-entirely-ASCII code you had copied, pasted and executed.
If you can see the file in your GUI file manager (hint) or mc
, then use its features to peek into / move / delete the troublesome file.
Or you can build a glob pattern that catches just the two files, temporarily move the real .bashrc
to another directory and use the pattern to refer to the sole impostor. Few ideas:
ls .b?shr?
ls .*b*a*s*h*r*c*
Thanks for the response. Unfortunately, I already knew all of this, but you did help me to realize that I accidentally wrote
pwd > ~/.bashrc
in my question when I meanpwd >> ~/.bashrc
. – joshisanonymous – 2019-05-03T14:22:24.763