0

With Ant you can use a filter like:

**/target/*.war

That means all the paths that have target in them as the last directory. This will match

  • a/b/target/X.war
  • a/target/Y.war
  • a/b/c/target/Z.war

I would like to be able to copy in ubuntu with this kind of filtering...

Best case would to do

cp **/target/*.war DESTINATION

I know this doesn't work. Is there some way in ubuntu I can achieve this?

Braiam
  • 67,791
  • 32
  • 179
  • 269

1 Answers1

1

In the bash shell, you can enable this behavior by setting the shell globstar option e.g.

$ shopt -s globstar
$ cp -v **/target/*.war ../target
`a/b/c/target/Z.war' -> `../target/Z.war'
`a/b/target/X.war' -> `../target/X.war'
`a/target/Y.war' -> `../target/Y.war'

You can turn the option off again (unset) with shopt -u globstar. Type help shopt at the bash prompt for more information about shell options.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • nifty... just a small question: does the option persist if the terminal is ended? I tested it, it doesn't – Michael Wiles Dec 17 '13 at 11:13
  • You can add it to the startup options in your ~/.bashrc file (in fact the default .bashrc has an entry for it which you can just uncomment i.e. remove the # in front of) – steeldriver Dec 17 '13 at 11:22