gpt4 book ai didi

shell - 用 shell(ubuntu) 查找单词并复制以下单词?

转载 作者:行者123 更新时间:2023-12-04 19:18:01 25 4
gpt4 key购买 nike

是否有可能在文件中找到一个单词而不是复制以下单词?

例子:

abc="def"
bla="no_need"
line_i_need="information_i_need"
still_no_use="blablabla"

所以第三行,正是我需要的行!

用shell命令可以找到这个词吗?

谢谢你的支持

最佳答案

使用 awk使用自定义字段分隔符更简单:

awk -F '[="]+' '$1=="line_i_need"{print $2}' file
information_i_need
-F '[="]+'将字段分隔符设置为 = 的 1 个或多个或 "

关于shell - 用 shell(ubuntu) 查找单词并复制以下单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30425883/

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