DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5236vfWL2698522 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 5236vfWL2698522 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=DluoUc8j X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFBEF3858C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1740985059; bh=kK+NteFst2tzmVzu8Ij06xRW7srnk0mSvirkaKWDKJw=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DluoUc8j9SvD9skIVJ3mm9QcdUEyHP+qPPNH4/zecDEHcet37fS6qICeoCZtE1F6r A7RvYLu1/Ffri1DdF2YXt6SpLwW9tU+/8ty67uJWCZkcTOqbWDMxgwyRpf+XNif1uv DU6yxrOWEjopACDYgwvmRKd9ZlfgpTYbgeaU0mhc= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 636793858D21 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 636793858D21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740985000; cv=none; b=acXozX/Nl3q2NABNPVvYuBeXpNM48Nu+SqWuMbNyLP1/nXFErgr4P06aQ1ZdELYd/dcLnaqNU65qe2DLG8/lH5Ea3pbqqU2us6CP+o5jk+fxgu2ivrcl7UX30UbGTadA3TneKD0f58opF8+R4lNVB1uS8/z9ZqT1G0QZXDdfk4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740985000; c=relaxed/simple; bh=xJt0PFoT85T3CFFQB1dguSeWIEEN7ilW3W9y0nFfaN0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=A3Stk5w2yQOCOZwu40+HAwu1GYX3tR1Zou4LGaAuVS6lg9mn8WjQHXdf5vUW/w2CGdzaO7OqEVjdEg4O49kcJZLfUx+rCiX5NOSKrNPD8Aup4WbvapZma8n1YFQt7I4b11sb/G/HKGz26WpgqViQZxabrWLCSio7nOgTDgVHIxM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 636793858D21 Date: Sun, 2 Mar 2025 22:56:39 -0800 (PST) X-X-Sender: jeremyd AT resin DOT csoft DOT net To: cygwin AT cygwin DOT com Subject: Re: cleanup of in-use files moved to recycle bin In-Reply-To: <2a781007-8b06-db4d-7bcc-59f45fbae8b8@jdrake.com> Message-ID: <881a1bd4-112c-9c9e-0dfa-babad34ddd55@jdrake.com> References: <2a781007-8b06-db4d-7bcc-59f45fbae8b8 AT jdrake DOT com> MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jeremy Drake via Cygwin Reply-To: Jeremy Drake Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Sun, 2 Mar 2025, Jeremy Drake via Cygwin wrote: > > 2) assuming there is not, I want to make a script using only things > > present in a "base system" to clean them up. > > Now that the mount points are escaped and contain the Windows volume roots > starting with 3.6, here's my script. It uses bash/find/gawk. I'd welcome > any ideas on improving it, I've only just started messing with gawk. (I'd > started out doing grep/cut then xargs printf "%b\0" to unescape, but with > gawk I can do that all in one program). > > It's in > https://gist.github.com/jeremyd2019/4984ff0fa1f6fd8c99d7b8b244c52088 I decided to try the grep/cut/xargs/printf method again, and found it shorter, so here it is. I also set up LC_CTYPE and LC_COLLATE to C.UTF-8 up front, in case some other locale/encoding is set up. I still have to override this to C for the find, because it doesn't seem to like the invalid unicode used by older Cygwin/MSYS2 versions for the binned files. #!/bin/bash -ex export LC_CTYPE=C.UTF-8 LC_COLLATE=C.UTF-8 IFS=. read -r cygmajor cygminor _ < <(uname -r) declare -a roots if [ "${cygmajor}" -gt 3 -o "${cygmajor}" -eq 3 -a "${cygminor}" -ge 6 ]; then # as of cygwin 3.6, volume roots are parsable from /proc/mounts # (noumount is the option that indicates a cygdrive mount) readarray -t -d $'\0' roots < <( cut -d' ' -f2,4 /proc/mounts | grep '\[^ ]*$' | cut -d' ' -f1 | xargs -d'\n' printf '%b\0') else # before that, just punt and look at the root of the drive / is mounted on root="$(cygpath -w /)" roots=("$(cygpath -u "${root:0:2}")") unset root fi declare -a trash readarray -t -d $'\0' trash < <( LC_CTYPE=C LC_COLLATE=C \ find "${roots[@]}" -maxdepth 1 -iname '$Recycle.Bin' -print0 | LC_CTYPE=C LC_COLLATE=C \ find -files0-from - -maxdepth 2 \( -name $'.\uDC6D\uDC73\uDC79\uDC73*' -o \ -name $'.\uF76D\uF773\uF779\uF773*' -o \ -name '.msys*' -o \ -name $'.\uDC63\uDC79\uDC67*' -o \ -name $'.\uF763\uF779\uF767*' -o \ -name '.cyg*' \) -print0) if (( ${#trash[@]} )); then ls -la "${trash[@]}" read -r -p "Remove? (y/N) " if [[ "${REPLY^^}" == "Y" ]]; then rm -f "${trash[@]}" fi fi -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple