Today I accidentally created a file whose name had a newline character in it. I didn’t notice it when I did it, but here’s how it showed up in my shell. There was a directory whose name shared the first few characters of the filename.
[22:07] james_simas@widget /var/tmp $ ls o*
oops? <--- Suspicious file!
oops: <--- Directory
I tried to delete it:
[22:07] james_simas@widget /var/tmp $ rm 'oops?'
rm: oops?: No such file or directory
Then I realized the my shell wasn’t interpreting the character right:
[22:04] james_simas@widget /var/tmp $ ls -b o*
oops\n
I tried deleting it again. No dice!
[22:08] james_simas@widget /var/tmp $ rm 'oops\n'
rm: oops\n: No such file or directory
Tab complete finally got it right:
[22:05] james_simas@widget /var/tmp $ rm 'oops
'