How do I change directories in a shell script while inside a loop?

时间:2017-06-04 23:47:54

标签: linux bash shell compression sh

I have over a thousand compressed files inside each other, named in descending order starting at 1022; and need to extract all of them. What I'm trying to do is to write a shell script that will do just that. Here's what I've got so far:

cd "PATH"

for file in PATH/*; do
    filename=${PWD: -4}

    extract $file

    numb=$(echo $filename - 1 | bc)
    echo $numb
    cd "$numb"
done

The "extract" function extracts any format of compression.

The problem is the loop doesn't seem to go on inside the new directory. Can anyone help me out with this?

0 个答案:

没有答案