I'm confused by this experiment (in Bash):
$ mkdir 'foo\n'
$ find . -print0 | od -c
0000000 . \0 . / f o o \ n \0
0000012
As you can see, "find" is correctly delimiting the output with null characters, but it escapes the newline in the directory name as "foo\n" with a backslash "n". Why is it doing this? I told it "-print0" which says "This allows file names that contain newlines ... to be correctly interpreted by programs that process the find output." The escaping should not be necessary, since "\0" is the delimiter, not "\n".
foo\n
, with a backslash in its name. – Michael Homer Feb 23 '19 at 06:36ls
you would have seen that. – Bakuriu Feb 23 '19 at 10:32ls
prints exactly what I passed to mkdir,'foo\n'
... – Metamorphic Feb 23 '19 at 10:42'foo'$'\n'
(at least my/bin/sh
– Bakuriu Feb 23 '19 at 20:37ls
would have helped me. But if I had known that '\n' did not signify a newline, then I would have seen this at themkdir
command.ls
did not show me anything I hadn't already seen. What would you think I learned from runningls
? I'm not saying I'm not dumb, just maybe a little more awake than you right now :) And why do people keep upvoting this question? It's my worst question! – Metamorphic Feb 23 '19 at 21:27