打击串爆炸 [英] Bash string explode

查看:88
本文介绍了打击串爆炸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件如下:

record=123
date=2012.01.20 10:22

在bash文件中,我执行cat myfile.ini,然后我需要使用诸如explode之类的东西,因为我只需要grep 123数字记录数据,而无需执行其他操作.

In the bash file I do cat myfile.ini, and then I need to use something like explode, because I need ONLY to grep the 123 numeric record data, and nothing else.

如何在bash中完成?

How it can be done in the bash ?

推荐答案

awk -F'=| ' '/record/ {print $2}'

在上面的命令中将日期"替换为记录"以获取日期(时间将在$3中).

Substitute "date" for "record" in the command above to get the date (the time would be in $3).

此键键入变量的名称,而不是取决于值的正则表达式匹配.它使用空格或等号作为字段分隔符.

This keys on the names of the variables rather than depending on a regex match of the value. It uses spaces or equal signs as field separators.

这篇关于打击串爆炸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆