上传一些新的操作脚本
This commit is contained in:
parent
2681c10b4c
commit
f5b3fedee3
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -36,4 +36,4 @@ __debug_bin
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
screenlog.*
|
screenlog.*
|
||||||
allapis.txt
|
*.txt
|
21
echo_service_path.sh
Normal file
21
echo_service_path.sh
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 初始化输出文件
|
||||||
|
output_file="server.txt"
|
||||||
|
echo "" > $output_file
|
||||||
|
|
||||||
|
# 遍历所有 *.api 文件
|
||||||
|
for api_file in server_api/*.api; do
|
||||||
|
# 提取服务名称
|
||||||
|
service_name=$(grep -oP 'service\s+\K\w+' $api_file)
|
||||||
|
|
||||||
|
# 提取所有以 get 或 post 开头的行,并使用 awk 获取路径
|
||||||
|
# 将结果保存在一个名为 paths 的数组中
|
||||||
|
paths=($(grep -E '^\s+(get|post)' $api_file | grep -oP '/\K[^/]*(?=/)' | sort | uniq | awk '{print "/"$1}' | tr '\n' ' '))
|
||||||
|
|
||||||
|
# 检查 $paths 是否为空,仅在非空时输出结果
|
||||||
|
if [[ ! -z "${paths}" ]]; then
|
||||||
|
# 将服务名称和路径组合成所需的格式,并将结果追加到输出文件
|
||||||
|
echo "$service_name [${paths[*]}]" >> $output_file
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user