我正在创建一个命令行 lint 工具以在 Linux 上运行。
我的输出目前看起来像这样:
./ex4/task6.7/SumOfCubedDigits.java
> Line 15 has inconsistent indenting
> Line 16 has inconsistent indenting
./ex2/task3.2/YearsBeforeRetirement.java
> Line 0 has a curly brace on the end
./ex2/task3.4/YearsBeforeRetirement.java
> Line 0 has a curly brace on the end
./ex2/task3.7/ThreeWeights.java
> Line 18 has inconsistent indenting
> Line 29 has inconsistent indenting
./ex2/task3.7/fourWeightsCoffeeTime/FourWeights.java
> Line 9 has inconsistent indenting
> Line 11 has inconsistent indenting
./ex2/task2.9/Limerick.java
> Line 0 has a curly brace on the end
通过管道输出,awk '/.\/ex/{print;}'
我可以只提取文件名:
./ex4/task6.7/SumOfCubedDigits.java
./ex2/task3.2/YearsBeforeRetirement.java
./ex2/task3.4/YearsBeforeRetirement.java
./ex2/task3.7/ThreeWeights.java
./ex2/task3.7/fourWeightsCoffeeTime/FourWeights.java
./ex2/task2.9/Limerick.java
我想依次打开这些文件中的每一个并对其进行编辑,可能会在我打开它们时向用户发送一条消息,其中包含每个文件中的错误。类似于 aspell 所做的。
这可能吗?