-
Notifications
You must be signed in to change notification settings - Fork 1
/
punzip
42 lines (31 loc) · 939 Bytes
/
punzip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env bash
usage() {
cat <<EOF
--requires GNU parallel--
This script will parallelize unzipping .gz files from a given directory into
another directory, while keeping the original archives intact. You may
optionally provide a search phrase to unzip only specific files. If the input
directory specified doesn't exist, one will be created. As a note, the directory
must end in a / (ex. ~/bonjovi/).
[Usage]
punzip <infiles.directory> <output.directory> <optional.search.phrase>
--Examples--
punzip ~/data/raw/ ~/data/processed/
punzip ~/data/raw/ ~/data/processed/ flounder
EOF
}
if [[ -z "$1" ]]; then
usage
exit 1
fi
echo "now unzipping into" $2
echo "if >2 compressed files and are >15gb, you may notice harmless system lag"
WORKDIR=$1
OUTDIR=$2
if [[ -z "$3" ]]; then
KEYWORD="*.gz"
else
KEYWORD=*"$3"*
fi
mkdir -p $OUTDIR
find $WORKDIR -name "$KEYWORD" | parallel gunzip -c {} '>' $OUTDIR{/.}