如何根据壳中的恒定变量来解析动态变量?
我正在尝试根据我在文本文件中找到的信息来解析两个不同的文本文件,并填充2个配置文件。
这是我使用的:
grep -w -o 50000 granmap.txt
。
响应:50000
,这很好,但是我想要遵循该值的一些信息。
文本文件中信息的格式如下:
50001 |仪器| ATMS
,
其中50001是常数,“仪器”使文件可读取,而“ atms”是文件之间的更改(这是我想要的信息)。从本质上讲,我想搜索文件以找到50001,以查找与之相等的内容。在这种情况下,50001 = ATM。
如何搜索50001,跳过仪器并抓住ATM位置的价值?也许有一种比使用GREP更强大的方法?
I'm trying to parse two different text files and populate 2 configuration files based on the information I find within the text files.
Here's what I am using:
grep -w -o 50000 GranMap.txt
.
Response: 50000
, which is good, but I want some of the information that follows that value.
The format of the information within the text files is as follows:
50001|Instrument|ATMS
,
where 50001 is the constant, "Instrument" makes the file human readable, and "ATMS" is what changes between files (and is the information I want). In essence, I want to search the file for 50001 to find what is it equal to. In this case 50001 = ATMS.
How can I search for 50001, skip over Instrument, and grab the value that is in the location of ATMS? Maybe there is a more powerful way to do this than using grep?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
态“文本
ID值可以像这样传递到awk中:
awk is quite good for this kind of "field oriented" text
The id value can be passed into awk like this: