#!/bin/bash files=($(find $1 -type f -name "*.proto")) paths=() filenames=() for file in ${files[@]}; do path=$(dirname $file) filename=$(basename $file) # paths+=("$path") # filenames+=("$filename#*.") if [ "${filename#*.}" = "grpc.proto" ]; then # 打印文件名 protoc -I="$path" $filename --cpp_out="$path" --grpc_out="$path" --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` elif [ "${filename#*.}" = "proto" ]; then protoc -I="$path" $filename --cpp_out="$path" fi done