I have many directories and I want to zip them all.
$ mkdir -p one two three
$ touch one/one.txt two/two.txt three/three.txt
$ ls -F
one/ three/ two/
I use zip
and it works as intended:
$ zip -r one.zip one
adding: one/ (stored 0%)
adding: one/one.txt (stored 0%)
$ ls -F
one/ one.zip three/ two/
But when I used this in a loop using zsh, zip files are created elsewhere.
$ for dir in */; do
for> echo "$dir";
for> zip -r "$dir.zip" "$dir";
for> done
one/
adding: one/ (stored 0%)
adding: one/one.txt (stored 0%)
three/
adding: three/ (stored 0%)
adding: three/three.txt (stored 0%)
two/
adding: two/ (stored 0%)
adding: two/two.txt (stored 0%)
$ find . -name "*.zip"
./three/.zip
./two/.zip
./one/.zip
$ ls -F
one/ three/ two/
I expected an output like this:
$ ls -F
one/ one.zip three/ three.zip two/ two.zip
What's going on?