I have this bash script to unzip files with different passwords. But it decompresses indefinitely and damages the decompressed files
PASS="passfoo passbar passfoobar"
LIST=$(ls -1 *.{zip,7z,7z.001,rar})
for password in $PASS; do
OIFS="$IFS"
IFS=$'\n'
for i in $LIST
do
echo "$password"
7z x -y -p"$password" "$i" -aoa
if [ $? -eq 0 ]; then
continue
fi
done
IFS="$OIFS"
done
To temporarily fix it I have had to create a loop for each password.
What I want is that when the script matches a password, the script won't test the others, and if there is no match with any password that tries to decompress it normally (if it does not have a password) or that shows an error (if the file has a password but it is not in the variable) without stopping to decompress the other files. Thk
PD: Keep in mind that files to decompress sometimes come with names with space and other non-ASCII characters, or are files compressed by parts