untaring multiple files

Hi,
i'm pretty new to unix and shell scripting and i need to untar a load of files all with different names e.g. YAAN00.V404.T13467.tar, YAAN00.V404.T15623.tar etc with the .T* part following no particular series.
I tried to untar them in a script using simply

tar -xvf YAAN00.V404.T*.tar

but it doesnt work. Can anyone help??

Thanks in advance,
RINCEBOY

Hi rinceboy, from the Solaris tar man page:

Note the words 'single file'. If you have to extract from multiple files, just run the files through a for loop.

try this

for next in `ls YAAN00.V404.T*.tar`
do
echo "Untaring - $next"
tar -xvf $next
done

You can do it from inside a script or from the command line.
If from the command line once you tye the "done", it will execute.

If you wanted to be more succinct you could use:

find . -name "YAAN00.V404.T*.tar" -exec tar xf {} \;

How does it work?

The find command looks in current dir (.) for files matching the -name clause then for each file it executes the tar xf command substituting the file name for {} the \; marks the end of the command to be exec'd (I think).

NB. This command will recurse into sub-directories aswell.

PS. The tar command does not allow you to untar multiple files as it assumes the first argument after f is the tar file and any further arguments are files you would like to extract from the tar file. This allows you to pick individual files from a tar file if you wish.