あなたはこれらのファイルの名前を一致させるためのfind
-regex
オプションを使用することができます -
find . -type f -regextype posix-extended -regex '.*ABC_20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])([0-2][0-3])([0-5][0-9])([0-5][0-9])\.sha1'
は、簡単なグロブパターンマッチングを行い-name
旗の上に、このためfind
でサポートされている-regex
フラグを使用しています。
find
のman
ページは-regex
のためのより低いと言う: - このpage
で
-regex pattern
File name matches regular expression pattern. This is a match
on the whole path, not a search.
-regextype name
This option controls the variety of regular expression syntax
understood by the ‘-regex’ and ‘-iregex’ tests. This option is
positional; that is, it only affects regular expressions which
occur later in the command line. If this option is not given, GNU
Emacs regular expressions are assumed.
posix-extended
正規表現の種類についての詳細。他のサポートされている正規表現型はhere
です。
$ ls ABC_2016*
ABC_20161231225950.sha1 ABC_20169231225990.sha1
$ find . -type f -regextype posix-extended -regex '.*ABC_20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])([0-2][0-3])([0-5][0-9])([0-5][0-9])\.sha1'
./ABC_20161231225950.sha1
アップデート: - - :regextype
はfind
バージョンではサポートされていない場合
、-name
フラグを使用して簡単なグロブ構築物がに使用することができますアクションでそれを見るために
同じ達成する。
$ ls ABC_2016*
ABC_20161231225950.sha1 ABC_20169231225990.sha1
$ find . -type f -name 'ABC_2[0-9][0-9][0-9][0-1][0-2][0-3][0-9][0-2][0-2][0-5][0-9][0-5][0-9].sha1'
./ABC_20161231225950.sha1
ありがとうございました。しかし、find as FTPコマンドを発行する必要があります。これらのパターンファイルは、FTPサーバーに存在します。 FTPサーバーで 'find'コマンドが機能しますが、オプションは認識されません。 :( – user1999315
@ user1999315: '-name'フラグだけを使って解決策を紹介してください。 – Inian