简体   繁体   中英

Catchin a text in Linux-Shell Script

How can I catch the text in specific table which is seen with another code on cli? Or how to catch the text in same design another way?

That is sample table

***pool-name             subnet               mask-len  vr-id
--------------------  -------------------  --------  -----
dataoam               10.254.140.160       27        0***

and I need a dataoam

It is a bit unclear which command you are using, ("networking show all..." does not name an actual command on my system), but assuming a given command yields your output, you can use tail and awk:

<your command> | tail -n +3 | awk '{print $1}'

Example:

jvc@BlueBuilder:~$ cat out.txt
***pool-name             subnet               mask-len  vr-id
--------------------  -------------------  --------  -----
dataoam               10.254.140.160       27        0***

and

jvc@BlueBuilder:~$ cat out.txt | tail -n +3 | awk '{print $1}'
dataoam

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