Dugan Chen's Homepage

Various Things

Deleting lines with find and sed

Now here’s a use case that calls for command-line Unix tools.

I use Slackware Linux. Slackware Linux includes, in its /extra directory, packages that are not installed by default. This includes a script to package Google Chrome. The Chrome packaging script includes Chrome dependencies, including ORBit2 and GConf.

Still with me?

A very popular repository of scripts to build Slackware packages for third party software is SlackBuilds.org. SlackBuilds.org is so popular that a frontend has been developed, called SBoPkg. SBoPkG allows you to queue up scripts to build and install in order. You can save those queues and pass them around. Not surprisingly, there’s a large repository of prebuilt SBoPkg queues that you can just download and use.

SlackBuilds.org also includes ORBit2 and GConf. Therefore, some of the prebuilt queues include instructions to build and install those packages from SBo (short for SlackBuilds.org). But what if I don’t want to do that? What if I just want to keep the packages that I got with Slackware? One possible solution is to just remove the lines referring to them from each queue.

It’s easy. The queue files are all in one directory (/var/lib/sbopkg/queues) and they all have an .sqf extension. The lines I want to remove are “@ORBit2” and “@GConf”. So, in that directory, I do this:

find *.sqf -exec sed -i '/@ORBit2/d' {} \;
find *.sqf -exec sed -i '/@GConf/d' {} \;