File size: 1,065 Bytes
ba431fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Check for argument representing the directory to perform the compression operation in
if [ -z "$1" ]; then
    echo "Please provide the directory to perform the compression operation in"
    exit 1
fi

# Go to the directory
cd "$1"

# Check if there is any jsonl file in the directory
if [ -z "$(find . -name '*.jsonl' -print -quit)" ]; then
    echo "[SKIP] no jsonl files found : $1"
    exit 0
fi

# Check if there is an existing result-jsonl.tar.gz file in the directory
if [ -f "result-jsonl.tar.gz" ]; then
    # Check if any of the jsonl files have been modified since the last compression
    if [ "result-jsonl.tar.gz" -nt "$(find . -name '*.jsonl' -print -quit)" ]; then
        echo "[SKIP] no change found for : $1"
        exit 0
    fi
fi

# Compress the jsonl files
echo "[START] Compressing jsonl files in $1"
find . -maxdepth 1 -name '*.jsonl' -print0 | sort -z | tar --no-recursion --null -T - -cf - | gzip -n > .tmp.result-jsonl.tar.gz
mv .tmp.result-jsonl.tar.gz result-jsonl.tar.gz
echo "[DONE] result-jsonl.tar.gz created in $1"