3

I want to create a file that is called ascii 007, which is the bell symbol, which is not printable. I tried nano $'\007', but that just created a file called ?; cat ? print the test content, that I placed in the file.

So how do I create a file, with a name set by the ascii encoding and not plainly spelled out?

0

1 Answer 1

5

Everything has probably actually worked as you expected, but you have been misled by two different phenomena:

  • ls and some other utilities display ? for non-printable characters by default
  • ? is a glob that matches a single character

That results in the following behaviour:

$ echo foo > $'\007'
$ ls
?
$ cat ?
foo

So it seems like we have a file that is literally named ?, right? Actually, that's just a happy coincidence of the two above phenomena -- the file is still called ^G:

$ printf '<%q>\n' *
<$'\a'>
$ ls -lb
total 0
-rw-r--r-- 1 chris chris 0 Aug  1 14:20 \a

Probably everything worked as you expected, despite what immediately appeared to indicate that the file was literally called ?.

1
  • The -b option can be used to tell ls to display the C-style escapes for non-printable characters. Commented Aug 1, 2013 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .