Getting name of file inside a rar without unrar

502 views Asked by At

Trying to get a bash script together, however I'm stuck at this. The rar is splited into x files, within the rar is 1 single file. What I'm doing is as below:

cd $dir
for rarfile in $(find -iname "*.part1.rar")
        do
                echo "Rar file: " $rarfile >> $dir/execute.log
                name = $(unrar lb "$rarfile")
                echo "Name of file inside rar container: " $name >> $dir/execute.log
                extension ="${name##*.}"
                echo "Extension: " $extension >> $dir/execute.log
                filename = ${name%.*}
                echo "Name: " $filename >> $dir/execute.log
#               unrar x -y -o- $rarfile $uprar_dir
        done

The excecute.log is as below:

Rar file:  ./file.part1.rar
Name of file inside rar container:
Extension:
Name:

Cant seem to get the $name working. The unrar is however working fine as it should. Pls help.

1

There are 1 answers

0
ciekawy On BEST ANSWER

in bash to assign value to a variable you cannot have spaces ie:

name=$(unrar lb "$rarfile")

instead of:

name = $(unrar lb "$rarfile")