Question: I have three commands in one shell script: `wget`, `7z`, and `rm`.

Inside list.txt 

```
URL1 archive_01.zip  
URL2 archive_02.zip  
URL2 archive_03.zip

```

Download archives:

```
while read -r url filename; do
    wget -O "$filename" "$url";
done < list.txt  

```

> 
> $ ls  
> 
>  archive\_01.zip  
> 
>  archive\_02.zip  
> 
>  archive\_03.zip
> 
> 
> 

Extract archives:

```
for file in *zip; do
    7z x $file;
done

```

> 
> $ ls  
> 
>  archive\_01.zip  
> 
>  archive\_02.zip  
> 
>  archive\_03.zip  
> 
>  folder\_01  
> 
>  folder\_02  
> 
>  folder\_03
> 
> 
> 

Delete archives:

```
rm *zip

```

Is it possible to make these three commands into a nested loops? If so, how?

I'm also curious, because the commands above will be executed like this (if I'm not wrong):

> 
> Download URL1 > Download URL2 > Download URL3  
> 
>  Extract Archive1 > Extract Archive2 > Extract Archive2  
> 
>  Delete Archive1 > Delete Archive2 > Delete Archive3 
> 
> 
> 

how to make the execution be like this?

> 
> Download URL1 > Extract Archive1 > Delete Archive1  
> 
>  Download URL2 > Extract Archive2 > Delete Archive2  
> 
>  Download URL3 > Extract Archive3 > Delete Archive3 
> 
> 
>

Answer: 
Something like this?

```
#! /bin/bash -

while read -r url filename; do
    wget -O "$filename" "$url"
    7z x "$filename"
    rm -- "$filename"
done < list.txt

```
```
while read -r url filename; do
  wget -O "$filename" "$url";
  7z x $filename
  rm $filename
done < list.txt  

```

should do what you want.