Advertisement
linuxyamigos

Untitled

Aug 31st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 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. echo "$file"
  10.  
  11. if [ -f "$file" ] ; then
  12. case "$file" in
  13. *.tar.bz2) tar xjf "$file" ;;
  14. *.tar.gz) tar xzf "$file" ;;
  15. *.bz2) bunzip2 "$file" ;;
  16. *.rar) unrar x "$file" ;;
  17. *.gz) gunzip "$file" ;;
  18. *.tar) tar xf "$file" ;;
  19. *.tbz2) tar xjf "$file" ;;
  20. *.tgz) tar xzf "$file" ;;
  21. *.zip) unzip "$file" ;;
  22. *.Z) uncompress "$file";;
  23. *.7z) 7z x "$file" ;;
  24. *) echo "'"$file"' cannot be extracted via ex()" ;;
  25. esac
  26. else
  27. echo "'"$file"' is not a valid file"
  28. fi
  29. }
  30.  
  31. ex "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement