Muffinresearch Labs by Stuart Colville

Extracting a single file from a tar backup | 1 Comment

Posted in Code, Linux/Unix on 12th November 2007, 12:49 am by

Like an idiot I accidentally overwrote a file for this blog when uploading some other stuff; accidents happen. Anyway, I have backups (you do have backups right?) and I needed to grab a single file out of the latest tar. Fortunately this is really straight forward and rather than unpacking the entire backup of all sites + dbs just to get one file you can use something like this:

tar -xf backup.1194753607.tar --wildcards *blah/index.php

As the manual states the wildcards flag enables globbing. Here’s a quick hack to flatten the output. Instead of creating the directory structure the -O flag is used to send the output to stdout and then redirect that output into the file index.php.

tar -xf backup.1194753607.tar -O --wildcards *blah/index.php > index.php

Post Tools

GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(3)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.542s.