staging.inyokaproject.org

zip - Ordner ausschliessen

Status: Ungelöst | Ubuntu-Version: Ubuntu MATE 20.04 (Focal Fossa)
Antworten |

CarstenHa

Anmeldungsdatum:
1. Mai 2020

Beiträge: 52

Hallo zusammen,

ich bin beim Coden auf eine Sache gestoßen, wo ich die Lösung schon gefunden habe, die ich aber noch nicht so ganz verstehe und ich nun auf Eure Hilfe hoffe.

Ich möchte im Terminal mit zip ein Archiv erstellen und einen bestimmten Ordner ausschließen.

1
2
3
4
5
6
7
8
# Beispiel 1: Ordner dir2 wird nicht in Ziparchiv erstellt
zip -vr file.zip ../dir -x ../dir/dir2/\*

# Beispiel 2: Erstellt einen leeren Ordner dir2 (ohne mögliche Dateien in diesem Ordner) im Ziparchiv.
zip -vr file.zip ../dir -x ../dir/dir2/**\*

# Beispiel 3: Funktioniert nicht
zip -vr file.zip ../dir -x ../dir/dir2

Meine Fragen:

Zu Beispiel 1: Ich dachte immer, * wird hier auf Dateien/Ordner im Ordner dir2 angewendet. Wieso wird hier der Ordner nicht mit erstellt?

Zu Beispiel 2: Ist **\* "zipspezifisch"? Wofür stehen die ersten beiden ** ?

Zu Beispiel 3: Warum funktioniert diese Möglichkeit nicht? Kann man nur Dateien ausschließen?

Vielen Dank schon mal ...

tomtomtom Team-Icon

Supporter
Avatar von tomtomtom

Anmeldungsdatum:
22. August 2008

Beiträge: 52312

CarstenHa schrieb:

Kann man nur Dateien ausschließen?

Laut manpage:

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