Escludere i file in un ciclo for


3

Voglio eliminare la directory / lib all'interno dei file apk. Sono riuscito a farlo con:

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

ora voglio escludere i file che hanno vvs o tita nel nome del file. non ho davvero idea di come farlo.


Vuoi comprimerlo o semplicemente cancellarlo?
terdon,

Risposte:


2

Questa -x file|directory|listè la tua chiave

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

Dalle pagine man:

   -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.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.