From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 146C91382C5 for ; Wed, 5 May 2021 14:24:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 82D23E087F; Wed, 5 May 2021 14:23:59 +0000 (UTC) Received: from mail.tzend.de (mail.tzend.de [185.244.193.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E5B75E0876 for ; Wed, 5 May 2021 14:23:58 +0000 (UTC) Received: by mail.tzend.de (Postfix, from userid 112) id 99BDF9A04EB; Wed, 5 May 2021 16:23:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tastytea.de; s=mail; t=1620224637; bh=gEFbOhpDgcxxtaFXhKGvQvaySr8Xvo/HdzylYmmZZf8=; h=Date:From:To:Subject:In-Reply-To:References; b=Yu9TuLJQ5RvYHRLIkv59Yp/0LU4RVCMGeN32CGA9NHYbKRrOI1BO6Hd9b5iNuRa1w Cbwz8p6sjC1qUI3yAD3tqa7d2+W1qnw51zwRMXcOVEsXcTPtHdoVx9HAM2zBy5ioyX yibj/7/bJwaXojxK0qFN7A7fB44/FFico0ugK9cc= X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on pla.tzend.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=ham autolearn_force=no version=3.4.5 Received: from ventiloplattform.tastytea.de (p200300c087015000ba25b005a1b7b6eb.dip0.t-ipconnect.de [IPv6:2003:c0:8701:5000:ba25:b005:a1b7:b6eb]) by mail.tzend.de (Postfix) with ESMTPSA id E66189A04B6 for ; Wed, 5 May 2021 16:23:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tastytea.de; s=mail; t=1620224631; bh=gEFbOhpDgcxxtaFXhKGvQvaySr8Xvo/HdzylYmmZZf8=; h=Date:From:To:Subject:In-Reply-To:References; b=G6h1q6a38retzcWZ0S9pKXmAQNReIcLBxGteXa7GLZzrAOLMUww/oKUj8g22suOO0 3FWPJ87w9yCuApGBoZSQg/udku31QxMCA0slRR4OIYhpsBeUpYT+IjYgRdrAobULUb LJT5XBb99+3mrMofG4UKa+AycTGtT4NmGNLLvOrI= Date: Wed, 5 May 2021 16:23:49 +0200 From: tastytea To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Re: [OT] tar exclude syntax tip Message-ID: <20210505162349.06cdc970@ventiloplattform.tastytea.de> In-Reply-To: References: <20210505160303.58ba6a67@ventiloplattform.tastytea.de> Jabber-ID: tastytea@tastytea.de Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/ls4iilPYrm8fGd.glrsSHaZ"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Archives-Salt: f12cfe6a-1299-4fd1-91df-1e698762d5c3 X-Archives-Hash: bdd5c7669918b0c7b650fbca56fa5d87 --Sig_/ls4iilPYrm8fGd.glrsSHaZ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2021-05-05 15:10+0100 (Nuno Silva) wrote: > On 2021-05-05, tastytea wrote: >=20 > > On 2021-05-05 09:33-0400 "Walter Dnes" > > wrote:=20 > >> tar version > >>=20 > >> #################################################### > >> tar (GNU tar) 1.34 > >> Copyright (C) 2021 Free Software Foundation, Inc. > >> License GPLv3+: GNU GPL version 3 or later > >> . This is free software: you are > >> free to change and redistribute it. There is NO WARRANTY, to the > >> extent permitted by law. > >>=20 > >> Written by John Gilmore and Jay Fenlason. > >> #################################################### > >>=20 > >> I'm passing on this solution to help others avoid my frustration > >> and wasted time. If you've done "RTFM" on tar, you'll find out > >> that "TFM" is broken or out-of-date or whatever, re: > >> "--exclude=3DPATTERN". I'm fighting the urge to turn this into a > >> rant. Here's my situation... > >>=20 > >> I either log in as root or "su -" and then "cd /home". I want to > >> tar up /home/waltdnes, and transfer it to another machine. While > >> I'm at it, I want to exlude directory /home/waltdnes/.cache/ and > >> all *.xz files in directory /home/waltdnes/pm/ The "--exclude=3D" > >> never worked. After much hair pulling, I was ready to give up on > >> the exclude, and simply transfer all the unnecessary garbage. > >>=20 > >> Then "I asked Mr. Google". It seems that I wasn't the only > >> person running into problems. After some searching, I finally > >> found a syntax that works... > >>=20 > >> #################################################### > >> #!/bin/bash > >> export GZIP=3D-9 > >> tar cvzf wd.tgz --exclude ".cache/*" --exclude "pm/*.xz" waltdnes > >> #################################################### > >>=20 > >> Notes... > >>=20 > >> 1) This is obviously not in line with the man page. Specifically, > >> "--exclude" is followed by one space, not an equals sign. > >>=20 > >> 2) ***THERE MUST BE EXACTLY ONE SPACE BETWEEN EACH WORD*** > >>=20 > >> 3) All directories and/or files to exclude must be listed as > >> relative paths to the directory being tarred, i.e. last parameter > >> on the command line. > >>=20 > >> 4) I don't know the maximum line-length, which would limit the > >> number of --exclude entries. In those cases, I wonder if > >> "--exclude-from=3DFILE" works as "--exclude-from FILE". > >> =20 > > > > This works fine here with =E2=80=9Ctar (GNU tar) 1.34=E2=80=9D: > > > > $ mkdir -p a/b > > $ touch a/file a/b/file > > $ touch a/file.xz a/b/file.xz > > $ tree a > > a > > =E2=94=9C=E2=94=80=E2=94=80 b > > =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 file > > =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 file.xz > > =E2=94=9C=E2=94=80=E2=94=80 file > > =E2=94=94=E2=94=80=E2=94=80 file.xz > > > > 1 directory, 4 files > > $ tar -cvzf test.tar.gz --exclude=3D"a/file" --exclude=3D"a/b/*.xz" a > > a/ > > a/file.xz > > a/b/ > > a/b/file > > $ tar -tf test.tar.gz > > a/ > > a/file.xz > > a/b/ > > a/b/file > > > > You can find out the maximum length of the command-line with=20 > > `getconf ARG_MAX`. =20 >=20 >=20 > But does it work with a space instead of =3D as well? According to the > online manual page, it should work both ways. >=20 Yes. It also works with 10 spaces. --=20 Get my PGP key with `gpg --locate-keys tastytea@tastytea.de` or at . --Sig_/ls4iilPYrm8fGd.glrsSHaZ Content-Type: application/pgp-signature Content-Description: Digitale Signatur von OpenPGP -----BEGIN PGP SIGNATURE----- iHUEAREKAB0WIQQ1VSZoZMptf/RapufPw5SX8bJuBwUCYJKqdgAKCRDPw5SX8bJu B43eAP9ocRFL8yP2/FJEFoCxNIzHA5A1wSq2fg19SkpGVcUs3QD9H3q2pu064SQu +01fZmtZXkRnCRaC4ftO711KzZiO/bE= =2Kqw -----END PGP SIGNATURE----- --Sig_/ls4iilPYrm8fGd.glrsSHaZ--