Recursively extract all compressed files in a dir

Today i need to upload some tar.gz files to ftp server then i want to extract them. one way was to extract each file individually. Then i thought to write a simple shell script to extract them because i have ssh access to that server. So this is the simple script to extract all the tar.gz compressed files in a directory.

for user in $( ls *.tar.gz )
tar zxvf $user

if you have zip file then change the *.tar.gz to *.zip and tar zxvf to unzip. If you have tar.bz2 file change tar zxvf to tar jxvf


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s