LINUX.ORG.RU

Не могу сообразить с find.


0

0

А как найти с помощью find например все видео файлы. find . -iname '*.avi' -iname '*.mpg' и find . -iregex '.*\.(avi|mpg)$' не работают.

И как найти все файлы как с точкой вначале, так и без неё, а то согласно find(1) "The metacharacters (`*', `?', and `[]') do not match a `.' at the start of the base name"

anonymous

Ответ на: комментарий от anonymous

-name pattern Base of file name (the path with the leading directories removed) matches shell pattern pattern. The metacharacters (`*', `?', and `[]') match a `.' at the start of the base name (this is a change in findutils-4.2.2; see section STANDARDS CON- FORMANCE below). To ignore a directory and the files under it, use -prune; see an example in the description of -wholename. Braces are not recognised as being special, despite the fact that some shells including Bash ibmue braces with a special meaning in shell patterns. The filename matching is performed with the use of the fnmatch(3) library function.

anonymous
()
Ответ на: комментарий от anonymous

       -name pattern
              Base  of  file  name  (the  path  with  the  leading directories
              removed) matches  shell  pattern  pattern.   The  metacharacters
              (`*',  `?',  and `[]') match a `.' at the start of the base name
              (this is a change in findutils-4.2.2; see section STANDARDS CON-
              FORMANCE  below).  To ignore a directory and the files under it,
              use -prune; see an example in  the  description  of  -wholename.
              Braces  are  not  recognised  as being special, despite the fact
              that some shells including Bash  ibmue  braces  with  a  special
              meaning  in  shell patterns.  The filename matching is performed
              with the use of the fnmatch(3) library function.

anonymous
()
Ответ на: комментарий от anonymous

там pattern -- не регексп и скобки никак не действуют

anonymous
()
Ответ на: комментарий от anonymous

> find . -name \*jpg | wc

Да не. Мне надо найти за раз файлы нескольких расширений. По поводу \*jpg - это понятно - я у себя поставил вместо \ кавычки.

anonymous
()
Ответ на: комментарий от anonymous

> The metacharacters (`*', `?', and `[]') match a `.' at the start of the base name (this is a change in findutils-4.2.2

Гм. Значит у меня старый find.

> там pattern -- не регексп и скобки никак не действуют

Не понял. У меня ж написано: find . -iregex '.*\.(avi|mpg)$'. iregex - регексп с игнорированием регистра.

anonymous
()
Ответ на: комментарий от anonymous

А понял. Запись '.*\.(avi|mpg)$' - extended regex, т.е. то что в egrep, а не в grep. Но все равно первая часть вопроса в силе - как найти все avi и mpg за раз.

anonymous
()
Ответ на: комментарий от anonymous

Хе-хе. Надо смотреть что запускаешь. Я так запускал без -exec

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.