Shell script required to uncompress and untar files

I need a shell script to Uncompress untar all the files present in the directory (it should Uncompress an untar files present in its sub folders also)

In my work I get lots of tar files to untar and update the server, for this each time in need to type

Step1) � Uncompress xyz1-3.tar.z�
Step2) � tar -xvf xyz1-3.tar�

This I have to do at least 20 times for a single set of documents sent to me.

Please help me.

Have you tried:

# zcat xyz1-3.tar.z|tar -xvf -

All the best

You need to take an entire directory and all subfolders? Here's how. Throw this into a script and run it:

#!/bin/ksh
# Descend Current Directory unless target directory provided on command line
# Find all files with "tar.z" and uncompress and then tar extract them into current
# directory (or 2nd argument on command line)
PATH=/usr/local/bin:/usr/bin:/bin
SDIR="${1:-.}"
TDIR="${2:-.}"
find $SDIR -type f -name "*.tar.z" -print |
while read file; do
   echo -n "Processing $file..."
   if zcat $file | tar xfC - $TDIR ; then
     echo "done"
   else
     echo "ERROR"
   fi 2>extract.$$.log
done

if test -s extract.$$.log; then
 echo "Errors:"
 cat extract.$$.log
else
 rm  -f extract.$$.log
fi