Skip to content

Instantly share code, notes, and snippets.

@nikoheikkila
Created July 12, 2012 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikoheikkila/3099766 to your computer and use it in GitHub Desktop.
Save nikoheikkila/3099766 to your computer and use it in GitHub Desktop.
Bash: Bzip2 compress given files in directory
#!/bin/bash
#
# bzcomp
# Bzip2 compress given files in directory
#
# Example usage: bzcomp logs/ '*.log' 4
#
# Author: Niko Heikkilä
# Version: 1.0.1
#
CWD=$1 # Working directory
RULE=$2 # String matching the filename(s)
LEVEL=$3 # Compression level {1..9}
find "$CWD" -name "$RULE" -exec bzip2 -v"$LEVEL" {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment