On Sun, 26 Feb 2006, Mike Miller wrote: > On Sun, 26 Feb 2006, Brian Hurt wrote: > >> On Sun, 26 Feb 2006, Ed Wilts wrote: >> >>> On Sun, Feb 26, 2006 at 08:36:39AM -0600, Jordan Peacock wrote: >>>> Quick question: I have a whole ton of .tar files I need to extract, >>>> but when I try 'tar -xvf *.tar' it doesn't work.... what am I doing >>>> wrong? >>> >>> Try: >>> >>> find . -name '*.tar' -exec tar xvf {} \; >> >> That will extract all tar files in the current directory and all >> directories under it. Which may be the behavior desired- but may not be. >> My for loop only extracts the tar files in the current directory. > > > Right. And you have to be careful with tar files about what they are putting > out. One might have contents that write over those of another one. Does > each one produce a unique directory and put all files in that directory? The > for loop is safer, but you should know before you run it what those tar files > contain. The nice thing about a for loop is that you can do more stuff inside a for loop than just a single command. For example, if you wanted to create a directory for each tar file, and untar it into it's own directory, you might do: for i in *.tar; do mkdir `basename $i .tar`.dir cd `basename $i .tar`.dir tar xvf ../$i cd .. done Brian