Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g100pon #23 ディレクトリを走査して特定のファイルを抽出
- //
- // 例 : カレントディレクトリ以下にある htmlファイル を列挙
- // groovy findfile '.*.html'
- //
- if( args.length<1 ){
- println 'Usage: groovy findfile regex'
- System.exit(0)
- }
- regex = args[0]
- recur = {
- if( it.isDirectory() )
- it.listFiles().each{ recur(it) }
- else
- if( java.util.regex.Pattern.compile(regex).matcher( it.name ).find() )
- println it.canonicalPath
- }
- recur(new File('.'))
Add Comment
Please, Sign In to add comment