I have two directories: dir1 and dir2 In dir1 I have files like:
- blacklist1.dat.bz2
- blacklist2.dat.bz2
- blacklist3.dat.bz2
and so on.
In dir2 I have encrypted files like:
- blacklist1.dat.bz2.enc
I would like to encrypt all the files that (comparing dir1 with dir2) doesn't exist on dir2. For encrypt a file I use Openssl: - openssl enc -aes-256-cbc -in dir1/file -out dir2/file.enc -k Password
I did like this but I'm missing the condition of the if
for i in /dir1/*; do
name=$(basename "$i")
test=$name.enc
if [ **<$test doesn't exist on dir2>** ]; then
openssl enc -aes-256-cbc -in dir1/name -out dir2/name.enc -k Password
fi
done