gpt4 book ai didi

linux - 创建 aspell 样式文件编辑 bash 脚本

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:01:28 28 4
gpt4 key购买 nike

我正在创建一个在 Linux 上运行的命令行 lint 工具。

我的输出目前是这样的:

./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 的作用。

这可能吗?

最佳答案

:

演示:

enter image description here

代码:

file=/path/to/file.txt

trap '\rm -f /tmp/out_file' 0 1 2 3 15

if dialog \
--clear \
--title "Pick up one of these files" \
--menu "Files/errors" 80 300 100 $(
awk '/>/{
$1=""
gsub(/ +/, "_", $0)
arr[k]=arr[k] $0
next
}
{k=$0}
END{for (a in arr) printf "%s ", a " " arr[a]}
' "$file") 2>/tmp/out_file
then
$EDITOR "$(</tmp/out_file)"
fi

关于linux - 创建 aspell 样式文件编辑 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19618881/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com