I mean to gzip all files *.vtu
, at all depths below a given directory, in bash.
I have such files at depths 1 and 2 below ./
.
I managed to do so with
$ gzip -v $(find . -name "*.vtu")
I could also use find ... -exec
, and other combinations (see below).
Is there any way of doing it only with a capability of gzip (-r
was my candidate)?
I expected
$ gzip -r -v "*.vtu"
where the pattern would not be expanded by the shell but expanded by gzip
(and in a way to produce my intended result!), would work for this, but I get gzip: ...: No such file or directory
with all combinations I tried.
What I found is the following:
- With
shopt -s globstar
(from here), the commandgzip -v **/*.vtu
seems to do exactly what I want. - If
shopt | grep globstar
givesglobstar off
, the command above does not work. In this case, I can usegzip -v */*.vtu
, but it only works with files at depth=1. Likewise withgzip -v */*/*.vtu
at depth=2.
In any case, I didn't find what is the effect/usefulness of flag -r
.
Related: