Skip to content

Instantly share code, notes, and snippets.

@anon-hui
Last active July 2, 2018 08:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anon-hui/937687aee391b0a2209da20b53550226 to your computer and use it in GitHub Desktop.
Save anon-hui/937687aee391b0a2209da20b53550226 to your computer and use it in GitHub Desktop.
compress file using best command between, gzip, gzip -9, bzip2, bzip2 -9, lzma, lzma -9. (bash shell) Usage "$ . zip.sh filename". th_TH:บีบอัดไฟล์โดยเลือกคำสั่งที่ดีที่สุดระหว่าง, gzip, gzip -9, bzip2, bzip2 -9, lzma, lzma -9.
. /dev/null
set -- "$1" "`wc -c -- "$1" | tee /dev/stderr | awk '{print$1}'`" '' :
echo "${@:2}" ;
set -- "$1" "$2" "`gzip -c -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' gzip
set -- "$1" "$2" "`gzip -c -9 -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' gzip -9
set -- "$1" "$2" "`bzip2 -c -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' bzip2
set -- "$1" "$2" "`bzip2 -c -9 -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' bzip2 -9
set -- "$1" "$2" "`lzma -c -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' lzma
set -- "$1" "$2" "`lzma -c -9 -- "$1" | wc -c`" "${@:4}"
echo "${@:2}" ; (( "$3" < "$2" )) && set -- "$1" "$3" '' lzma -9
echo "${@:2}" ;
set -- "${@:4}" -- "$1"
echo "$@" ;
"$@"
. /dev/null
@anon-hui
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment