bash - Returning only a part of the string from a grep result -


this question has answer here:

i'm using grep on text file containing simple logs in following form:-

[abc.txt] 1=abc|2=def|3=ghi|4=hjk|5=lmn|6=opq 8=rst|9=uvx|10=wyz . . . . 

and on

the values tags 1,2,3,4 etc different throughout file , include special characters in case too. there way can retrieve value tag 4 , no other tags via grep?

btw,this log file result of grep .so please advice if should redirect output first , apply second grep or apply second grep on first one,considering it's large file.

you pipe result of grep cut, split fields "|" , select fourth field

[your grep command] | cut -d | -f 4 

if want "4=" gone can same using cut second time time using "=" delimiter.

http://pubs.opengroup.org/onlinepubs/009695399/utilities/cut.html


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -