lm-eval-data / scripts /build-jsonl-archive-in-folder.sh
picocreator's picture
updated compression / decompression scripts
6aa6f83
raw
history blame
1.07 kB
#!/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"