www.delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Message-ID: | <41EF54F1.7090807@hotpop.com> |
Date: | Wed, 19 Jan 2005 22:51:29 -0800 |
From: | Alex <alex DOT p AT hotpop DOT com> |
Reply-To: | alex-p AT hotpop DOT com |
User-Agent: | Mozilla Thunderbird 1.0 (Windows/20041206) |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Couple of scripts to remove duplicate packages |
X-Authentication-Info: | Submitted using SMTP AUTH at out008.verizon.net from [4.11.13.110] at Thu, 20 Jan 2005 00:51:28 -0600 |
--------------090407090601040705000505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I have a habit of keeping cygwin packages on my computer and updating them from time to time using setup.exe. This saves me time when I need to install on another computer. This creates a problem of old versions of packages accumulating in my download directory. I used to remove them by hand but that is a time consuming process. Finally I wrote an awk script to help me deal with the problem. And just for kicks I added a shell wrapper :). Attached are the scripts. I hope they could be useful to someone else. I am sure they can be improved but they have been useful to me as is. Thanks, Alex --------------090407090601040705000505 Content-Type: text/plain; name="cyg-remove-dups.awk" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cyg-remove-dups.awk" #! /bin/awk BEGIN { \ last_pkg = ""; last_date = 0; last_dir = ""; last_pkg_name = ""; cmd = "find release -type f -printf '%h %f %TY%Tm%Td\n'"; while(( cmd | getline ) > 0) { dir = $1; pkg = $2; date = $3; count = split(dir, part, "/"); if( last_pkg_name == part[count] ){ if( date < last_date ){ print dir "/" pkg; continue; }else{ print last_dir "/" last_pkg; } } last_pkg = pkg; last_date = date; last_dir = dir; last_pkg_name = part[count]; } close(cmd); } --------------090407090601040705000505 Content-Type: text/plain; name="cyg-remove-dups.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cyg-remove-dups.sh" #! /bin/bash # Version of cyg-remove-dups in bash, just for kicks. Still uses awk and find # awk is used in a normal way. Trick is to pass program to it with the data # on stdin. find release -type f -printf "%h %f %TY%Tm%Td\n" | \ awk -- ' BEGIN { \ last_pkg = ""; last_date = 0; last_dir = ""; last_pkg_name = ""; } { dir = $1; pkg = $2; date = $3; count = split(dir, part, "/"); if( last_pkg_name == part[count] ){ if( date < last_date ){ print dir "/" pkg; next; }else{ print last_dir "/" last_pkg; } } last_pkg = pkg; last_date = date; last_dir = dir; last_pkg_name = part[count]; } ' --------------090407090601040705000505 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------090407090601040705000505--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |