I wrote a batch decompression shell with the password rar, which can be decompressed to a folder with the same file name as RAR. If necessary, please refer to it.
#!/bin/bash
#-----------------------------------
#Batch unzip the RAR with password to the directory with the same file name
#-----------------------------------
#Unzip password
pwd='123456'
for i in *.rar
do
#Directory name
dname=$(echo $i|sed 's/.rar//')
mkdir ./$dname
#Determine whether the directory was created successfully
if [ -d "$dname" ]
then
Echo - e "directory $dName created successfully \ n" > > ur log
#Decompression operation
/usr/bin/unrar x -p$pwd $i ./$dname
#Judge whether the decompression is successful
if [ $? -eq 0 ]
then
Echo - e "decompression of $I succeeded \ n" > > ur log
else
Echo - e "decompression of $I failed \ n" > > ur log
fi
else
Echo - e "failed to create directory $dnmae \ n" > > ur log
fi
done