0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

shellscript でログデータを加工した時のメモ

0
Posted at

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
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?