bulk pkg_delete (FreeBSD) | Unix Linux Forums | BSD

  Go Back    

BSD BSD, sometimes called Berkeley Unix, is a Unix operating system developed by the Computer Systems Research Group of the UC Berkeley.

bulk pkg_delete (FreeBSD)


Closed Thread    
Thread Tools Search this Thread Display Modes
Old 08-30-2004
erebus47 erebus47 is offline
Registered User
Join Date: Aug 2004
Last Activity: 29 October 2004, 10:49 AM EDT
Location: /dev/null
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bulk pkg_delete (FreeBSD)

I have been toying with this all night now and cannot seem to get it to work, so I came to you for some aid. I recently discovered the wonders of the AWK programming language and how it can be useful of UNIX system administratioin, especially directly from and interacitive interpreter (ala sh).

The FreeBSD development team made it very easy to install pre-compiled binary packages remotely via the pkg_add -r directive which gives you functionality and facility very similiar to that of Debian's famed APT. When issuing a fetch, you do not have to give a specific version number along with the package name in the string, so something such as this will work fine:

# pkg_add -r <package>

One little incovinience that I did come across is, of course, having to look for specific version numbers each time I want to remove a package via the pkg system. This process was tedious and involved looking through pkg_info output for your program and maybe piping it to 'more' or 'less' to scroll through a long list of packages:

# pkg_info | less

long list of packages here

# pkg_delete <package_version>

This might not seem like a lot to the naked eye, and indeed, it takes but a minute to accomplish, but it does get rather boring and is a minute that could have been well spent elsewhere. I was thinking about how I might accomplish this more time effective.

I needed pkg_info's output to accomplish the bulk of this, so that goes first. I would then have to pipe it to some pattern matching utility and search for my program, which, of course, would not have to be specific. Their is two options here, and my first was the less efficient, but the first to come to mind. The second saves a process. The third will eliminate the need for yet another process. The problem with this and what I need help with will unfold:

# pkg_info | grep xchat | awk '{ print $1 }' | xargs pkg_delete

# pkg_delete `pkg_info | grep xchat | awk '{ print $1 }'`

# pkg_delete `pkg_info | awk '/xchat/ { print $1 }'`

This little timeline was how I wrote this in the exact order. The last one is what I stuck with, though. The basic operation of this script is as follows: output package information, look for records with the string "xchat", extract only the first field from the output, and delete the package.

Here is my problem. I have a gnome installation that I would like to get rid of via package managment for the sake of cleanliness. I could do this manually, though it would take me ages to go through every single package with the method above. I tried the following to delete the bulk of the gnome packages:

# pkg_info | awk '/gnome/ { print $1 }'              

For all of the above package, I got the a message similar to the following for each:

pkg_delete: file '/usr/X11R6/share/gnome/help/charpick_applet/it/figures/charpick_applet.png' doesn't really exist

After a minute or two, I ran this and got the same message as above:

# pkg_info | awk '/gnome/ { print $1; system("pkg_delete" $1); }'

This is the end of the road, and I hope someone might have a solution to this. I was thinking it was going to be something recursive, but i'm studying up on awk a bit more. Thanks in advance...


I just did "man pkg_delete" and came across the -x switch. Here's what it does, which is what the above does too:

     -x      Treat the pkg-name as a regular expression and delete all pack-
             ages whose names match that regular expression.  Multiple regular
             expressions could be provided, in that case pkg_delete deletes
             all packages that match at least one regular expression from the

I ran "pkg_delete -x gnome" and got the same errors i got early, plus a new one:

pkg_delete: couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)

And that's the update.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bulk Fixes Selection mrmurdock AIX 4 06-21-2010 01:19 PM
Bulk move in ssh command Deei Shell Programming and Scripting 0 05-28-2010 11:19 AM
outcomment bulk congo Shell Programming and Scripting 3 08-01-2007 12:29 AM
bulk mail as a background job HungryH UNIX for Dummies Questions & Answers 2 01-01-2002 10:15 AM

All times are GMT -4. The time now is 10:12 AM.