gpt4 book ai didi

linux - 如何根据部分输入来grep完整单词?

转载 作者:太空宇宙 更新时间:2023-11-04 06:03:55 25 4
gpt4 key购买 nike

我有一个文件text.txt,其中包含以下单词。

 1. moon,one
2. sun,two
3. well,three
4. doll,four

如果我使用sungrep这个文件

grep -i sun text.txt

我会得到输出

sun,two

但是,我的要求是我需要grepsun开头的单词而不是sun。

grep -i sunlight text.txt

这里我需要与 grep -i sun text.txt 相同的输出。

最佳答案

您不需要 awk 或 gawk,也不需要 sed。就这么做

grep -o 'sun.*'

根据您使用的系统,可能还提供其他更复杂/优雅的解决方案。

关于linux - 如何根据部分输入来grep完整单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52942382/

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