You are not logged in.
Pages: 1
Hi all,
After I read this article, http://www.dwheeler.com/essays/fixing-u … names.html (with which I actually agree in most points), I wondered how one can create files with such weird names.
I tried a lot, but did not succeed in it.
I am interested in this, because I am writing a php script that will parse user input to "ls". Allthough I guess I will just forbid all weird filenames and restrict them to the Portable Filename Character Set, I still was interested (just for the heck of it).
I guess such things can be done with C quite easily, but is it possible with Bash? Have any of you ever experimented with black arts like this?
Eager to know about your dirty hacks
jocom
Offline
I've accidentally made filenames with newlines in before. It's a pain when you don't realise you've done it
My friend has a Mac, and for some godforsaken reason that lets him make files with slashes in the name.
Offline
I've accidentally made filenames with newlines in before.
So how did you do that?
Offline
touch "hello
"
Quotes can be evil >.>
Offline
Ok, that worked
Allthough "ls" displays it as '?', but "echo *" displays a nice blank line.
But how about other metacharacters? I guess they are harder...
jocom
Offline
'touch "?foo"' works here. Just experiment a bit.
Offline
Ok, that worked
Allthough "ls" displays it as '?', but "echo *" displays a nice blank line.
But how about other metacharacters? I guess they are harder...jocom
> $(echo -e bell:'\007')
don't drink unwashed fruit juice.
i never make predictions, especially about the future.
Offline
'touch "?foo"' works here. Just experiment a bit.
True. That one is not very hard. Nor is the space: "touch \ ". I did not yet find a way for getting the \t tab character in a filename.
But the harder ones, in my eyes are control characters 1-31 or 127.
Offline
Tab:
[karol@black bbb]$ touch "$(echo -e "ab\tc")"
[karol@black bbb]$ ls
ab?c
[karol@black bbb]$ ls -b
ab\tc
[karol@black bbb]$ echo *
ab c
Last edited by karol (2011-01-13 18:01:57)
Offline
Hmz, I am getting the hang of it. You can even input the filenames by hitting (Ctrl-V) (Ctrl-x), where x denotes some control character. For example
$ touch foo^Hbar # Ctrl-V Ctrl-H gives the ^H
$ echo *
fobar
So in the output the second 'o' of "foobar" is 'backspaced' {huge grin}!
Offline
'ls --show-control-chars' should be equal to 'echo *'
[karol@black bbb]$ ls --show-control-chars
fobar
[karol@black bbb]$ ls --quoting-style=literal
foo?bar
[karol@black bbb]$ ls --quoting-style=escape
foo\bbar
From the ls man page:
--quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape
Offline
You can specify any character in bash by the following syntax $'\xHH' (HH is the hexadecimal code of the character). Some specific syntax are also supported.
Some funny file names
touch beep$'\x07'
give a file name with a beep in it (echo * will give you an audible beep; ls seems to filter these funny characters).
touch Hello$'\n'World
give a file name with a newline in it (again visible by echo *).
Last edited by olive (2011-01-13 20:02:47)
Offline
This is fun! I indeed recognized the beeping filename
So what is the best 'filename hack' that you guys can think of?
I thought of ETX or EOT characters in filenames, but it did not give funny results with 'echo *'.
What do you think?
jocom
Offline
Pages: 1