Jordan,

In the "for" command the find is not contained in backticks. Right after the
last command and before the semicolon there needs to be a backtick as well. I
would also think you need to tell find what you want to do once the file is
found either an -ls or -print command.

I would suggest checking the content of $i before the case command to see what
it contains.


Something like the following.
#!/bin/bash
for i in `find . -name '*.tar' -o -name '*.rar' -o -name '*.zip' -print`; do
echo $i
  case $i in

Just a thought.

Don Sparish

Quoting Jordan Peacock <hewhocutsdown at gmail.com>:

> Brian, I have a question about your code specifically, as I've been
> trying to modify it, without success. Here's the current incarnation:
>
> #!/bin/bash
> for i in `find . -name '*.tar' -o -name '*.rar' -o -name '*.zip'; do
>  case $i in
>    *.tar)
>       mkdir `basename $i .tar`.dir
>       cd `basename $i .tar`.dir
>       tar xvf ../$i
>       cd ..
>       ;;
>    *.rar)
>       mkdir `basename $i .rar`.dir
>       cd `basename $i .rar`.dir
>       unrar e ../$i
>       cd ..
>       ;;
>    *.zip)
>       mkdir `basename $i .zip`.dir
>       cd `basename $i .zip`.dir
>       unzip -d ../$i
>       cd ..
>       ;;
>  esac
> done
>
> The find definately works. I've tested that. But I haven't been able
> to get any of the rest to actually do what it's supposed to, and I
> don't understand what's happening clearly enough. So....
>
>    *.tar) # this is the case identifier
>       mkdir `basename $i .tar`.dir   # making a new directory, with $i
> being all characters before .tar. What is the significance of basename
> or the single quotes? Does .dir change it's 'extension' to a
> directory?
>       cd `basename $i .tar`.dir  # we're moving into the newly made
> directory, although i'm not sure why the .tar stuff is still there;
> it's a directory now, right?
>       tar xvf ../$i   # we execute tar and look for the file $i in the
> parent directory
>       cd .. # moving back into the parent dir for the next file
>       ;; # denotes end of case
>
>
> I'm experiencing some errors at the cli as well;
>
> line 18: unexpected EOF while looking for matching ``'
>       cd `basename $i .zip`.dir # this is the trouble line
> line 25: syntax error: unexpected end of file # there is no line 25 ?
> The code ends at 24.
>
> I have to say a huge thank you to everyone who has contributed. I know
> these are kind of stupid questions, but the shell scripting tutorials
> aren't covering a lot of this. Thank for stepping me through this
> beginner shell script.
>
>                                                        -jordan
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>