Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to find files that have a newline in the filename. But I can't figure out what pattern to use.

The following works, but is not very useful if I want to use it in indented code.

find . -name '*

I tried these two and they only succeeded in finding filenames that contained the letter n:

find . -name '*\n*'
find . -name "*\n*"

Then I found how to write backslash escape sequences and tried this:

find . -name "*$'\n'*"

But that doesn't find anything. How should I write the pattern?

share|improve this question
up vote 4 down vote accepted

In shell scripting, everything is a string. You do need to quote the * to prevent filename expansion, but you don't want to put the backslash escape sequence inside double quotes.

You could just concatenate the strings by placing them right after each other.

find . -name '*'$'\n''*'

But for better readability, you can use ANSI-C Quoting for the whole string.

find . -name $'*\n*'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.