Question : How to write a shell script to untar files?

I'd like to write a shell script that untars files within a directory.

I tried the code below, but get an "unexpected token" error.
Code Snippet:
1:
2:
3:
4:
#!/bin/bash
file=ls ./*.tar.gz
do tar -xvzf $file
done
Open in New Window Select All

Answer : How to write a shell script to untar files?

try

#!/bin/bash
for file in *.tar.gz
do
     tar -xvzf $file
done
Random Solutions  
 
programming4us programming4us