csplit command

Let’s say you have a single file (a mysql dump) containing the output of multiple database backups… and you want to split them out into individual files.

Input fil:

# MySQL dump 7.1


# Host: localhost Database: Purchase_Tracking



# MySQL dump 7.1


# Host: localhost Database: Test



Use the following csplit command to break the files up, based on the presence of the # Host: localhost line…

$ csplit -f db inputfile.dmp ‘/# Host: localhost/’ {*}

The above will create a series of files named db00, db01, db02, etc. for as many files as necessary.

Posted in Mac OS X | Leave a comment

Using rarcrack on Ubuntu

Rarcrack is an open source rar file password cracker.  Use it when you’ve forgotten the password you put on a rar or zip file.  The current version (0.2) doesn’t work flawlessly on Ubuntu, so follow these steps.
1. Download the source:
wget http://downloads.sourceforge.net/project/rarcrack/rarcrack-0.2/%5BUnnamed%20release%5D/rarcrack-0.2.tar.bz2
2. Un tar
tar -xjf rarcrack-0.2.tar.bz2
3. Change directory
cd rarcrack-0.2
4. Type make, hit enter.  You will likely receive an error about a memory.h file that can’t be found.
5. Install libxml2-dev
sudo apt-get install libxml2-dev
6. Run make again
7. You will now have a rarcrack file that you can use.  If you use it as such you may receive a Segmentation Fault
./rarcrack filename.rar
use the –type parameter instead
./rarcrack --type rar filename.rar
It should then run properly
Posted in Mac OS X | Leave a comment

BASH script to remove numeric prefix from files downloaded from scribd

Scribd is a great service, offering PDF downloads of a variety of content.  Unfortunately there is an ugly 8 digit (random?) number prefixed on each file downloaded.


It’s not descriptive, and it makes alphabetic sorting of the files downloaded impossible.  Here’s a small BASH shell script that will remove the first 9 characters (8 digits and the – character) from all pdf files in a directory.

for f in *.pdf; do
[ ! -f $file ] && mv "$f" $file

Create the above in a file, save it, and be sure to use chmod +x filename to make the shell script executable.

Posted in Mac OS X | Leave a comment

Combine multiple PDFs into a single file on Linux

One of the great features of the iPhone is the ability to load PDF files into the iBooks application… why lug paper around when you can have a huge amount of reading material right on your phone?

One of the challenges of this is that many freely available materials come as 1 chapter per PDF file: Linux Device Drivers is just one example.  The iBooks application remembers where you last left off when reading a PDF file, it also supports bookmarks.  As such, it makes for too much clutter to have multiple books with multiple files per chapter, too confusing to navigate and manage.

Using the GhostScript (gs) and pdftk tools we can easily combine multiple PDF files into one.  Both these tools are freely available on Linux.   The steps here were performed on Ubuntu 10.10

1. Install GhostScript and pdftk:

sudo apt-get install gs pdftk

2. Download the tarball of files:

wget http://lwn.net/images/pdf/LDD3/ldd3_pdf.tar.bz2

3. Unzip using bunzip2:

bunzip ldd3_pdf.tar.bz2

4. Un tar:

tar -xvf ldd3_pdf.tar

5. Change to newly created dir:

cd ldd3_pdf

6. Combine using GhostScript:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=ldd3.pdf -dBATCH TITLE.pdf ch01.pdf ch02.pdf ch03.pdf

(not all files listed)

7. There will now be an output file named ldd3.pdf that combines all the listed files in the order they were listed in the command arguments!

Posted in Mac OS X | Leave a comment

Installing Java Runtime Engine on Turnkey LAMP Appliance

Turnkey Linux offers a LAMP (Linux Apache MySQL PHP) appliance – an ISO or VM to install or create a pre-configured Linux based web server.  The install is very streamlined offering minimal bloat, as well as many other advantages: pre-installed and configured applications, text GUI configuration on initial boot, configured for automatic updates, based on a Long Term Support (LTS) version of Ubuntu.  However, it is laking a Java Runtime Engine, which is a requirement for some server applications , such as Real Chat.

To install the Java Runtime Environment (JRE) do the following: (steps generated using the 11.0 RC release of the LAMP stack appliance):

1. Install VM , after configuration exit to command line

2. Login as root

3. edit /etc/apt/source.list.d/sources.list

4. Add the following line (anywhere), then save and quit

deb http://archive.canonical.com/ubuntu lucid partner

5. apt-get update (we’re logged in as root, no need for sudo)

6. apt-get install sun-java6-jre

7. Follow installation prompts

8. Confirm installation using java -version:

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-bo4)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
Posted in Mac OS X | Leave a comment