AWS S3 に保存している tar.gz 形式で保存している json のログデータを加工する必要があった時以下のような shellscript で対応したというメモ
COPY_FROM=/path/to/copy_from
COPY_TO=/path/to/copy_to
cd COPY_FROM=/path/to/copy_from
aws s3 sync s3://target_bucket/target_data/ .
for nested_dir in $(ls -1 $COPY_FROM );; do
if [ ! -d $COPY_TO/$nested_dir ]; then
mkdir -p $COPY_TO/$nested_dir
fi
for target_file in $(ls -1 $COPY_TO/$nested_dir ); do
zcat $COPY_TO/$nested_dir/$target_file | \
jq -c 'del(.target_delete_key)' | \
gzip -c > \
$COPY_TO/$nested_dir/$target_file
done
done