Why does this fail?
touch "$(printf "a\nb")"; find . -regex './.\n.'
I also tried these, none of which work:
find . -regextype posix-extended -regex '.\n.'
find . -regextype posix-awk -regex '.\n.'
find . -regextype posix-basic -regex '.\n.'
find . -regextype posix-egrep -regex '.\n.'
The only way it seems to work is (thanks @MichaelMrozek)
find . -regex './.'$'\n''.'
Which is cumbersome to say the least. So, why do find's regular expressions seem to be unable to deal with \n
?
Update in response to answers so far:
OK, I understand that \n
is not part of ERE and that was one of my misunderstandings but find
claims to support posix-awk
and both gawk
and mawk
match \n
as expected:
$ printf "f1l1\nhas newline:f2l1#f1l2 does not:f2l2#" |
mawk -F: 'BEGIN{RS="#"}; ($1~/\n/){print $1}'
f1l1
has newline
I don't have a pure awk
to test with so perhaps POSIX awk
does not match? Otherwise is find
not actually implementing posix-awk
regular expressions?
find . -name $'*\n*'
cumbersome too? – devnull Mar 10 '14 at 17:07-regex
fails, not How to find files that contain newline in filename? which you answered perfectly :). – terdon Mar 10 '14 at 17:10awk
regex language does not know about\n
but that theawk
interpreter does and that's why it matches. Therefore, implementingawk
regexes asfind
does, would not imply that\n
should match. Thank you all! – terdon Mar 10 '14 at 17:54