Category: utilities
Author/Contact Info Aunir@hotmail.com
Description: FreeBSD users, are you tired of having to pkg_delete <extremely long and complex filename> over a series of related packages? Say for example, XFree86*****? I hacked this up to avoid much frustration in the process.
#!/usr/bin/perl -w

use strict;

open INFO, "pkg_info|grep XF|" or die can't smoke that pipe: $!";
#ok, so it's package specific...

chomp( my @input = &lt;INFO&gt; );
foreach(@input){
   s/(&#091;\w\.\-\,&#093;+)\s+.*/\1/;
   system "pkg_delete $_";
   print "$_ ==&gt;\n Deleted!\n";
}

#yeah, that regex looks ugly, but it worked.
#I guess I'm most proud that this is the first time I've really used p
+erl for something useful.
Replies are listed 'Best First'.
Re: pkg_delete for similar packages
by xiphias (Initiate) on Jun 27, 2002 at 03:56 UTC
    Is it just me or should
    ... or die can't smoke that pipe: $!";
    be
    ... or die "can't smoke that pipe: $!";
      aye, it should be. I typed the code in here, and accidentally missed the qoute. My apologies! --Aunir
Re: pkg_delete for similar packages
by kappa (Chaplain) on Jun 26, 2002 at 09:13 UTC
    This functionality is included in all moderately fresh FreeBSD versions. Try:
    % pkg_delete -n XFree86\*
    to see how to delete all XFree86 :)
      heh, I guess I should read the man pages sometime... But hey, at least this script works. I'm still proud of my first l'il useful script. /grin/. /aunir/