gpt4 book ai didi

sed - 删除包含小于/大于限制的数字的行?

转载 作者:行者123 更新时间:2023-12-02 04:35:28 26 4
gpt4 key购买 nike

我有很多这样的行,由 grep -n 生成:

path/to/dir/file1.txt:4: Match
path/to/dir/file1.txt:40: Another Match
path/to/dir/file2.txt:2: Match
path/to/dir/file2.txt:564: Yet another Match

我想删除行号小于(比如)10 的行。我知道我可以使用 cut -d: -f2 轻松获取行号,但你怎么能然后使用它来丢弃这些行并继续完整地输出其余的输出,这样你最终会得到:

path/to/dir/file1.txt:40: Another Match
path/to/dir/file2.txt:564: Yet another Match

最佳答案

你可以这样做:

your command | awk -F: '$2>=10'

关于sed - 删除包含小于/大于限制的数字的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22076934/

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