Экстракт на все времена

tar-gzНазвание конечно шуточное, но намекающее на то, о чем хочу написать. А написать я хотел на тему распаковывания файлов разных форматов. В очередной раз пытаясь сначала вспомнить параметры для распаковки файла, а потом и прочтения help, я понял, что меня это достало. И надо что-то с этим делать.

Итак, создадим shell-скрипт и назовем его extract. В качестве аргумента он будет получать файл и в зависимости от формата выполнять распаковку.  Сам скрипт имеет вид:

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

Поместим его в /usr/bin и сделаем исполняемым для всех пользователей.

43 комментария к “Экстракт на все времена

  1. Wonderful article. I discover something much more difficult on different blog sites day-to-day. It will constantly be stimulating to review web content from various other writers and also practice a something from their shop. I?d prefer to use some with the content on my blog site whether you don?t mind. Natually I?ll provide you a web link on your internet blog. Thanks for sharing.

  2. When I initially commented I clicked the -Notify me when new comments are included- checkbox and also now each time a comment is included I get four e-mails with the same comment. Is there any way you can remove me from that solution? Many thanks!

  3. Good day! I could have sworn I’ve been to your blog before but after going through a few of the posts I realized it’s new to me. Regardless, I’m definitely delighted I stumbled upon it and I’ll be book-marking it and checking back frequently!

  4. I’d like to thank you for the efforts you’ve put in writing this blog. I am hoping to see the same high-grade content by you in the future as well. In truth, your creative writing abilities has encouraged me to get my very own site now 😉

  5. Nice post. I find out something a lot more challenging on various blog sites day-to-day. It will constantly be promoting to check out material from various other writers as well as exercise a little something from their store. I?d like to use some with the web content on my blog site whether you don?t mind. Natually I?ll give you a web link on your internet blog. Thanks for sharing.

  6. Youre so great! I do not expect Ive read anything like this before. So nice to find someone with some initial thoughts on this subject. realy thank you for beginning this up. this website is something that is needed online, someone with a little creativity. beneficial task for bringing something brand-new to the web!

  7. Wonderful article. I learn something more difficult on various blogs everyday. It will certainly always be stimulating to review web content from other authors and practice a little something from their store. I?d like to use some with the material on my blog whether you don?t mind. Natually I?ll offer you a web link on your web blog. Thanks for sharing.

  8. When I initially commented I clicked the -Alert me when new comments are added- checkbox as well as currently each time a comment is added I get 4 emails with the very same remark. Exists any way you can remove me from that solution? Many thanks!

  9. There are some fascinating moments in this write-up yet I don?t understand if I see all of them facility to heart. There is some credibility but I will hold point of view until I look into it further. Great article, thanks and also we want extra! Contributed to FeedBurner also

  10. The following time I review a blog site, I really hope that it does not dissatisfy me as much as this set. I suggest, I recognize it was my selection to check out, however I actually thought youd have something interesting to claim. All I listen to is a lot of whimpering about something that you could take care of if you werent also hectic looking for attention.

  11. There are some interesting points in time in this write-up however I don?t understand if I see every one of them facility to heart. There is some validity yet I will certainly take hold opinion until I look into it further. Good article, thanks and also we want extra! Added to FeedBurner as well

  12. I?m impressed, I have to say. Actually rarely do I come across a blog site that?s both informative and also entertaining, and let me tell you, you have actually hit the nail on the head. Your idea is impressive; the concern is something that insufficient people are speaking smartly around. I am very delighted that I stumbled across this in my search for something connecting to this.

  13. This is the right blog for everyone who wishes to understand this topic.

    You realize so much its almost tough to argue with you (not that I personally would want
    to…HaHa). You certainly put a new spin on a subject that’s been written about for years.
    Wonderful stuff, just excellent!

  14. Great article. I find out something much more difficult on various blog sites daily. It will always be boosting to read web content from various other authors and practice a little something from their store. I?d choose to use some with the material on my blog site whether you don?t mind. Natually I?ll offer you a web link on your internet blog. Thanks for sharing.

  15. Somebody essentially assist to make critically posts I would state.
    That is the very first time I frequented your web page and thus far?
    I surprised with the analysis you made to make this actual post incredible.
    Excellent process!

  16. There are some fascinating times in this write-up but I don?t understand if I see every one of them center to heart. There is some legitimacy but I will certainly take hold point of view till I look into it additionally. Good write-up, many thanks and we desire a lot more! Included in FeedBurner as well

  17. This is the best blog site for any person that wishes to discover this subject. You understand so much its virtually tough to say with you (not that I really would want?HaHa). You certainly put a new spin on a subject thats been discussed for several years. Excellent things, simply great!

  18. Aw, this was a really great post. In idea I would love to place in creating similar to this additionally? taking time and also real effort to make a great article? yet what can I state? I put things off alot and also by no means seem to get something done.

  19. An impressive share, I just offered this onto a colleague who was doing a little evaluation on this. And also he in fact purchased me morning meal because I found it for him. smile. So let me reword that: Thnx for the reward! Yet yeah Thnkx for investing the time to review this, I really feel strongly regarding it and love finding out more on this subject. If possible, as you become experience, would you mind upgrading your blog site with more information? It is extremely useful for me. Big thumb up for this article!

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *