mplementations of
find
vary, but they should all handle character classes in wildcards (POSIX.2, section 3.13):find . -name '*[~*]*'
If newline is among your "special" characters, you may need to work out how to get your shell to pass it to find. In Bash, you can use
find . -name $'*[\t \n]*'
to show files containing whitespace, for example. A simpler method, if supported, is to use a character class:
find . -name '*[[:space:]]*'
----
f you want something more general than matching a specific character, you would have to use regular expressions. Since the question is not tagged "linux", the proper answer would use POSIX:
find . | grep '[*~]'
If you want to make it Linux-specific, you can use the GNU
find
option -regex
(also supported by FreeBSD). If the pathname has an embedded newline (rarely done, but used as a frequent counterexample), POSIX find
+grep
will not work. But with the -regex
extension, this "works" to print names which have embedded newlines:find . -regextype posix-awk -regex '.*[*~]'
although the manner in which find is used is not part of the question.
Further reading:
Nenhum comentário:
Postar um comentário