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?-regexfails, not How to find files that contain newline in filename? which you answered perfectly :).awkregex language does not know about\nbut that theawkinterpreter does and that's why it matches. Therefore, implementingawkregexes asfinddoes, would not imply that\nshould match. Thank you all!