Extract all Archive File Format With Just One Command in Linux

Linux, Uncategorized, bash January 28th, 2009

There are large number of archive file formats – .zip, .tar.gz, .tar, .gz, .7zip, .rar, etc etc..

I find it difficult to remember the command line options for extracting different archive file formats. So, I wrote a bash function which given a archive filename as an input extracts it.

Here’s the function :

extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract ()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

This function is pretty self explanatory. But as it is not powerful. It becomes the ultimate tool for extractive archive files if you copy this function in you bashrc file (~/.bashrc).

Now you can simply extract any file like this:


$extract test.tar.gz

Hope you like this function.

Note: This function doesn’t work with files have space in its name. I didn’t waste time in solving this issue as I normally don’t use such filenames. If any of you solve this issue, please do let me know. I would include it with your name in this post. :D

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

Dual Monitor with Nvidia in Ubuntu Hardy : A PhotoBlog

Uncategorized August 1st, 2008

Yesterday I bought my new 21.6″ LG LCD. Now, I have two LCDs one 20.1″ and the other one 21.6″. Here are few snaps and a screenshot. Enjoy  watching :)

Here’s the screenshot. Click to see the full size image.


Cool Workspace !! Ain’t it ?

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

Gedit : A Powerful Light-Weight IDE

GNOME, Linux, Uncategorized July 15th, 2008

Gedit can be transformed into a powerful light-weight IDE.

Before I tell you the steps take a look at the screenshot of my gedit:

gedit IDE

Now, if you are convinced that you also want to customize gedit read on …..

Step 1: Go to edit->Preferences and tick the options :

  • Display line numbers
  • Highlight current line
  • Highlight matching bracket

Step 2:  Click the ‘Editor’ tab in the preferences dialog box. Tick the option :

  • Enable Automatic indentation
  • [optional] change tab width to 4 or whatever width you think is appropriate for you.

Step 3: Download the darkmate theme : http://grigio.org/files/darkmate.xml Save the xml file on your desktop. Click the ‘Font & Colors’ tab in the Preferences dialog box. Click the Add button and then add the xml file downloaded just now. Darkmate theme should now be in the list of Color Scheme. Select the Darkmate theme. Or you can select any Color Scheme you like. You can get more themes from http://live.gnome.org/GtkSourceView/StyleSchemes

Step 4: Now install the package gedit-plugins . This can be accomplished by

$ sudo aptitude install gedit-plugins

(in Debian based system)

or

$ su

# yum install gedit-plugins

(in rpm based system)

After installing the gedit-plugins package open the tab ‘Plugins’ in the Preferences dialog box.

Tick the following plugins:

  • Bracket Completion – This will automatically print right brackt/parantheses for every left counterpart.
  • Code Comment – This plugin helps you in commenting a block of code
  • [optional] Color Picker – This is helpful for web designers to get the color code.
  • Draw Spaces – This plugin will draw an arrow for every tab and one dot for every space. You can configure the color of the space or tab by clicking the “Configure Plugin”
  • Embedded Terminal – This will embed a gnome-terminal at the bottom of your gedit window.
  • Execute Tools
  • File Browser Pane
  • Indent Lines – This plugin helps you in indenting a block of code.
  • Session Saver – This plugin helps you save different sessions.

You can check out other plugins according to your need.

Step 5 : You can get more gedit plugins like “Word Completion” and many more useful 3rd party plugins on this page – http://live.gnome.org/Gedit/Plugins

Download whatever plugin you wish and just place the extracted files in ~/.gnome2/gedit/plugins

You are done !

P.S: Please let me know if you find a useful plugin for gedit.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce