#!/bin/sh file="$1" shift case $file in *.tar) bsdtar -cvf "$file" "$@" ;; *.tar.gz|*.tgz) bsdtar -czvf "$file" "$@" ;; *.tar.xz|*.txz) tar -cvJf "$file" "$@" ;; *.tar.zst|*.zst) bsdtar -aczvf "$file" "$@" ;; *.rar) bsdtar -cf "$file" "$@" ;; *.zip) bsdtar -cf "$file" "$@" ;; *.7z) bsdtar -cf "$file" "$@" ;; *) print "It couldn't copress them\n" print "Usage:\n" print "compress file. foo1 foo2 fooN\n" return ;; esac