12 lines
357 B
Bash
12 lines
357 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# 遍历当前目录下的所有文件
|
||
|
for file in sy/*.c; do
|
||
|
# 检查是否为文件
|
||
|
if [ -f "$file" ]; then
|
||
|
# 使用sed命令进行查找替换
|
||
|
# 将形式为const int var = num;的文本替换为#define var num
|
||
|
sed -i 's/const int \([a-zA-Z_][a-zA-Z0-9_]*\) = \([0-9]*\);/#define \1 \2/g' "$file"
|
||
|
fi
|
||
|
done
|