获取指定字符串的行号
程序员文章站
2022-07-14 19:27:34
...
获取指定字符串的行号
file.txt:
------------------------------------------------------[BOARD_CFG]
PLATFORM = hisiv500
SERIAL = LEDxxX8800B
BOARD = LED43X8800B
MODEL = KONKA_TV
CODE = 99016870
BUILD_MODE = RELEASE
AN_VERSION = V2.3.06
AN_BUILD = 2476
DATE = 09:48:33 2016-11-08
[PNL_CFG]
PNL_NAME = PNL_72000915YT_LG43_LC430DUY-SHA2
PNL_NUM = 72000915YT
PNL_CODE = 99015414
PNL_BUILD = 2476
PNL_VERSION = V2.3.00
1、grep -nr AN_VERSION file.txt | awk -F: '{print $2}'
2、cat file.txt | awk '/AN_VERSION/ {print NR}'
上一篇: 深度寻路算法(C++实现)
下一篇: 【JavaScript】获取指定字符串