简体   繁体   中英

How to select rows with information in a text file by using linux command

I just want to select certain info in separated rows in a text file. How do I deal with this? 图片 For selecting row, which contains "SUBSCRIBERIDENTIFIER" and another row contains "LATEST_OFFLINE_TIME"

My output to look like following:
SUBSCRIBERIDENTIFIER=23481XXXXXX02
LATEST_OFFLINE_TIME=20170330191209

$ awk '/'"SUBSCRIBERIDENTIFIER"'/,/'"LATEST_OFFLINE_TIME"'/' file.txt
SUBSCRIBERIDENTIFIER=1923UIO1U23I1O
LATEST_OFFLINE_TIME=128390812903810983019

$ awk '/SUBSCRIBERIDENTIFIER/,/LATEST_OFFLINE_TIME/' file.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM