sysy/scripts/c2sy.sh

17 lines
615 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 这个脚本会递归查找当前目录及所有子目录下的.c文件并将它们的扩展名改为.sy
# 使用find命令查找所有.c文件
# -type f 指明我们只对文件类型感兴趣
# -name '*.c' 用来指定文件名模式
# 使用while循环处理find命令的输出
find . -type f -name '*.c' | while read fname; do
# 使用mv命令重命名文件
# ${fname} 是当前的文件名
# ${fname%.c}.sy 是新的文件名,%.c用于从文件名中去除.c后缀然后加上.sy
mv "${fname}" "${fname%.c}.sy"
done
echo "All .c files have been renamed to .sy files."