The script I use every day

The script I use most frequently is a script for extracting files. If you work from the linux command line, it is impossible to remember which program with which flags should be used to extract a file. This is something the computer should do for you! This extraction script solves the problem, and you can configure the first lines of the script to match any filetype. I use it so often that I have it aliased to ‘e’

You can see Martin Ankerl’s original post for some usage information, along with the obvious installation procedure

There is one thing about extracting files that can be frustrating- when the archive contains multiple files, and they are all dumped out from the archive, polluting the working directory. So i added onto the script the ability to prevent this directory pollution from happening. If there are multiple files in the archive, it guarantees they will be extracted into a directory. If it needs to create a directory, that directory will have the same name as the file (sans extenstion). It will also rename the extracted file/directory with a timestamp if the name is already taken by a file/directory in the working directory.

Download extraction script Here

I think this script shows of some of the strengths of ruby and why it is a great language for scripting

  • easy interaction with the OS
  • flexibility- Ruby is very object-oriented, yet I was not forced to write any object-oriented code
  • malleability- I used the ability to alias a keyword and add to an open class

There are some other tools with a similiar purpose, but they are not as easily extended by the user

  • atool Also has other useful abilities related to archives
  • unp

The other non-standard command line tool I use most frequently is ack, which is basically like combining find and grep, with nice color highlighting in the output.
What lesser known tools do you use most often?

© Greg Weber. All original code snippets are placed in the public domain.
Written on Fri Feb 1 00:59:26 2008.
Tagged as linux, ruby, script.
Send author an email.