I have a folder structure that looks like this:
0/1/2 and the numbers goes from {0..9}
I tried writing a bash shell script so that I can compress each of the folders like this:
#!/bin/bash
for i in {0..9};
do
cd $i
for j in {0..9};
do
cd $j
for k in {0..9};
do
tar -czvf $i$j$k.tar.gz $k;
done
done
done
It seems to be able to create the names for the .tar.gz files ok, but it won't traverse through the directory structure to be able to create them for each of the folders inside the folders.
I'm not 100% sure what I am doing wrong with this script.
What I want it to do is to go to 0/0/ and then create the .tar.gz file for folders {0..9}.
And then go to 0/1/ and do it again.
And then go to 0/2/ and do it again, etc.
Until all of the folders have been cycled through, and the .tar.gz files have been created.
It seems to just saying in 0/0/ and just keep compressing the same files over and over again, and it won't move on to the next folder.
Any help is greatly appreciated.
(Disclaimer: I'm not a programmer nor a developer, so this is new territory for me.)
(Background: this is for me to back up my Photoprism data storage (as it has about 2.5 million pictures and takes up about 1.6 TB of space or so). I tried sending it straight to LTO-8 tape and I guess that because there are so many small files, LTFS ran into an out of memory exception error such that when I eject the tape and try to load it back in, it automatically spits the tape back out because of said out-of-memory error; but that's a whole 'nother question. So I figure that if I compress the files, then it will have fewer files that LTFS is dealing with, and therefore; that should help fix the LTFS/LTO-8 tape drive error.)
Thank you.
cd
, but I don't see you ever coming back out of them...{0..9}
? Just the first zero or the others too?