JSON直接发shell脚本好了
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
suffix=${file#*.}
if [ "$suffix" == 'json' ];
then
file_path=$1"/"$file;
echo "Compressing $file_path";
jq -c . < "$file_path" > "$file_path.min.json"
rm "$file_path"
mv "$file_path.min.json" "$file_path"
fi
fi
done
}
read_dir $1
使用方法: ./compress 目录 就可以了,当前目录就是 ./compress .