我正在尝试对当前目录中的所有文件运行 indent -kr -i8
。作为一名 C 程序员,我想到的想法是 fork 等于文件数量的进程,并在它们上运行 exec。但我知道可以使用 shell 脚本简化事情。感谢任何形式的帮助。
最佳答案
你不仅可以:
indent -kr -i8 *.c
你提到了 fork 进程,所以如果你想同时进行:
for f in *.c
do
indent -kr -i8 $f &
done
但是如果你有一大堆文件,那会浪费 cpu。所以分批:
limit=10
for f in *.c
do
indent -kr -i8 $f &
(( count = count + 1 ))
if [[ $count -eq $limit ]] then
wait
count=0
fi
done
关于c - 如何编写缩进当前目录中所有文件 C/C++ 文件的 shell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9839286/