Advertisement
linuxyamigos

Untitled

Aug 31st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # ex - archive extractor
  4. # usage: ex <file>
  5. ex () {
  6. local args=$@
  7. local file=${args[@]}
  8.  
  9. if [ -f "$file" ] ; then
  10. case "$file" in
  11. *.tar.bz2) tar xjf "$file" ;;
  12. *.tar.gz) tar xzf "$file" ;;
  13. *.bz2) bunzip2 "$file" ;;
  14. *.rar) unrar x "$file" ;;
  15. *.gz) gunzip "$file" ;;
  16. *.tar) tar xf "$file" ;;
  17. *.tbz2) tar xjf "$file" ;;
  18. *.tgz) tar xzf "$file" ;;
  19. *.zip) unzip "$file" ;;
  20. *.Z) uncompress "$file";;
  21. *.7z) 7z x "$file" ;;
  22. *) echo "'"$file"' cannot be extracted via ex()" ;;
  23. esac
  24. else
  25. echo "'"$file"' is not a valid file"
  26. exit 1
  27. fi
  28. exit 0
  29. }
  30.  
  31. ex "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement