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 501FA1382C5 for ; Wed, 5 May 2021 14:03:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EFF66E0875; Wed, 5 May 2021 14:03:27 +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 903ACE086A for ; Wed, 5 May 2021 14:03:27 +0000 (UTC) Received: by mail.tzend.de (Postfix, from userid 112) id 1377E9A04EB; Wed, 5 May 2021 16:03:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tastytea.de; s=mail; t=1620223406; bh=mnY2dVWld0u4pKrRomzUQjU5Vglclk+Isd5FyJ5EwGI=; h=Date:From:To:Subject:In-Reply-To:References; b=QSr0Fi17ytwvsLvwlMfTCWwg4PqlETQhbPFWazJCYFGds+3TozKykQNKTxnK7l9fF SdP9Kpqla2qJMj5CDdJ2C0zJq8yDoZzkAOXglc+BLUAfK1GXz2J0YAo5pvVb7Abr+K i1/7jungo5vUC6y1765zLeQomN2sGZx6KT8MKv80= 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 7A7519A04B6 for ; Wed, 5 May 2021 16:03:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tastytea.de; s=mail; t=1620223405; bh=mnY2dVWld0u4pKrRomzUQjU5Vglclk+Isd5FyJ5EwGI=; h=Date:From:To:Subject:In-Reply-To:References; b=B4qFnd2kUxpG88tIYEc1a1FAaLELARRqGkhKHADDqfsUmdbQchxvBUEXa/rZp01kW S/qKkMnkedYFDlnyhKc/tswWjrGxm0IQzFPLJmfLWfFcetV4XR7aX84zuaynBg+CwC +2W/I1gqDadwfWui77OR3InhSCy7VGuZXopzdcyk= Date: Wed, 5 May 2021 16:03:03 +0200 From: tastytea To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] [OT] tar exclude syntax tip Message-ID: <20210505160303.58ba6a67@ventiloplattform.tastytea.de> In-Reply-To: References: 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_/gFJGFY1ebxus04QSlW_tO/e"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Archives-Salt: 4a759810-93b4-4e06-ba26-5f972d8fd42d X-Archives-Hash: 677e28cdb47e7740fa99aaaf49232236 --Sig_/gFJGFY1ebxus04QSlW_tO/e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2021-05-05 09:33-0400 "Walter Dnes" wrote: > 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 Get my PGP key with `gpg --locate-keys tastytea@tastytea.de` or at . --Sig_/gFJGFY1ebxus04QSlW_tO/e Content-Type: application/pgp-signature Content-Description: Digitale Signatur von OpenPGP -----BEGIN PGP SIGNATURE----- iHUEAREKAB0WIQQ1VSZoZMptf/RapufPw5SX8bJuBwUCYJKllwAKCRDPw5SX8bJu B3BNAPwPjVvvFUOHXwKqv9Tl1GV0xPR1S2QOPp+v5MA6ofvX7wD/eXq5Ghzc9r24 L8VmCwWCrK4v0bV/L8J7F/iKFU9lExQ= =DCac -----END PGP SIGNATURE----- --Sig_/gFJGFY1ebxus04QSlW_tO/e--