Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to delete the /lib directory inside apk files. I managed to do this with:

for DIR in ~/ABC ~/ABD 
 do
  cd $DIR
   for APK in *
    do
     if test -f "$APK"
      then
       zip -d $APK /lib*
     fi
   done 
done

now i want to exclude files that have vvs or tita in the filename. i really have no idea how to do that.

share|improve this question
    
Do you want to zip it or just delete it? –  terdon Apr 9 '13 at 15:49

2 Answers 2

The -x file|directory|list is your key

zip -d $APK /lib* -x *vvs* *tita*

From the man pages:

   -x files
   --exclude files
          Explicitly exclude the specified files, as in:

                 zip -r foo foo -x \*.o

          which  will  include the contents of foo in foo.zip while excluding
          all the files that end in .o.  The backslash avoids the shell filename
          substitution, so that the name matching is performed by zip at all
          directory levels.

          Also possible:

                 zip -r foo foo -x@exclude.lst

          which will include the contents of foo in foo.zip while excluding all
          the files that match the patterns in the file exclude.lst.

          The long option forms of the above are

                 zip -r foo foo --exclude \*.o

          and

                 zip -r foo foo --exclude @exclude.lst

          Multiple patterns can be specified, as in:

                 zip -r foo foo -x \*.o \*.c

          If there is no space between -x and the pattern, just one value is
          assumed (no list):

                 zip -r foo foo -x\*.o

          See -i for more on include and exclude.
share|improve this answer

Add an interior if statement, that uses one of these approaches to determining if $APK contains the strings 'vvs' or 'tita'

http://stackoverflow.com/questions/2829613/how-do-you-tell-if-a-string-contains-another-string-in-unix-shell-scripting

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.