This is the story of a guy who usually writes birthday posts on this birthday. This year calls for something completely different. Why? He feels that the posts could be perceived as boring and he agrees completely.
Usually, I’d write a post related to adding one year onto my age and stuff like that. Twenty-five. Well, now I don’t have to pay the underage fee to rent a car anymore! And my insurance should go down right? RIGHT?
Anyway, I’m sure those posts were boring to everybody else but me, so here’s something completely different:
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
}
Extract Anything (Bash)
This should go in your .bash_profile—now.
Did you do it yet? If you do have it, then isn’t it awesome? If not, then it’ll save you the hassle of trying to remember how to extract .tar, .tar.gz, bz2-whatever and .zip files on the command line! Sure, you might be a master with the tar zxvf stuff, but this is a must for those absent minded folk such as myself. :P
Well, with that I shall go celebrate being 25… and pondering how to get this geeky CLI feeling out of my system.
Congratulations on surviving another complete Earth rotation! Thanks for the gift of CLI knowledge!
Now, go have some fun.
Happy Birthday. There’s something liberating about being able to rent a car and not having to pay the “I’m a punk kid” driver mark-up or premium insurance rates because most kids under 25 floor their Chevy Cobalts from stoplight to stoplight. Ah the perks of avoiding natural selection and surviving for a quarter of a century.
Have a blow out bash.
Awesome tip, happy birthday. I just realized that this is the only site I refuse to read in my RSS reader. It’s much better in person.
Wohoo, awesome little function man. Definitely gonna add that in!
“. ~/.bash_profile” to reload without restarting shell session.
@Rob: I’m that “little punk kid” you’re talking about! Dreading turning 23…
Damn apple heads!!! :p…. Happy B-Day “B”, now go get drunk and do something stupid. Its the only day of the year that you can get away with it.
Happy birthday man, and thanks for the LCLI gift. You have no idea how many times I’ve spent a good 10 minutes looking at tar —help to figure out how to compress a simple file, hehe ^_^
Hope you have a good ‘un
thanks for the tip :) belated happy birthday :D
Happy Birthday, Bryan. And thanks for the bash tip.
Happy birthday! Thanks for this cool script.
Thanks you guys! The clock has struck midnight and reality finally sets in. ;) Glad you all like the script. I’ll definitely do more of these if I run into any more!
Your car insurance doesn’t go down that much…at least in New England. Maybe in one month when I hit the big 2-6.
Happy b’day — and what a useful script you have sir! Even if I am a day late…
@dimitry - if you’re asking what I think you’re asking.. about getting bash_profile to be read without restarting a session etc, you can use source to get OS X/*nix to reread the file.
source ~/.bash_profile
I have tiny balls…