[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: HS: tar exclure un dossier a la racine mais pas sous dossier



Pour les détails d'exclusion, voir man bash :
If the extglob shell option is enabled using the shopt builtin, several
       extended  pattern  matching operators are recognized.  In the following
       description, a pattern-list is a list of one or more patterns separated
       by a |.  Composite patterns may be formed using one or more of the fol‐
       lowing sub-patterns:

              ?(pattern-list)
                     Matches zero or one occurrence of the given patterns
              *(pattern-list)
                     Matches zero or more occurrences of the given patterns
              +(pattern-list)
                     Matches one or more occurrences of the given patterns
              @(pattern-list)
                     Matches one of the given patterns
              !(pattern-list)
                     Matches anything except one of the given patterns

Par exemple si tu veux exclure download et titi
tar -zcpvf test.tar.gz !(download|titi)

Bonne nuit,

Le dim. 19 mai 2019 à 22:50, Benoit B <benoitlst@gmail.com> a écrit :
>
> Oups je voulais écrire
>
> tar -zcpvf test.tar.gz !(download)
> Qui archivera :
> archive/
> archive/download/
> titi/
>
> et exclu le download du répertoire courent avec !()
>
> Le sam. 18 mai 2019 à 09:18, Jérémy Prego <jeremy@pregonetwork.net> a écrit :
> >
> > Bonjour,
> >
> > Je viens avec une petite question de NOOB sur tar ce matin. J'aimerai
> > faire quelque chose qui me parait simple en théorie mais ça me semble
> > plus compliqué en pratique.
> >
> > en fait, j'aimerai archiver un dossier mais en excluant un sous dossier
> > mais seulement dans la racine. je m'explique
> >
> > Pour l'exemple, le dossier s'appel toto. Dans toto il y a plein de sous
> > dossier dont un qui s'appel download. mais, il y a aussi un sous dossier
> > s'appelant archive, et qui contient aussi un dossier download.
> >
> > Je précise que quand je fais mon tar, je suis dans ce dossier "toto".
> >
> > à force de recherche, j'ai bien trouvé une commande tar qui me
> > conviendrait, mais seul souci, l'archive comporte un premier dossier "."
> > tar --exclude='./download' -zcpvf test.tar.gz .
> >
> > j'ai bien essayé de remplacer le point de la fin par un * et d'adapter
> > mon exclude en conséquence, mais j'ai pas réussi a obtenir le résultat
> > voulu...
> >
> > du coup, j'aimerai mixer les deux. À savoir, avoir directement mes
> > dossier a l'ouverture de l'archive, et ne pas avoir le contenu du
> > premier dossier download.
> >
> > merci pour l'aide,
> >
> > Jerem
> >


Reply to: