Original file FinalResults.txt contains the following:
loginName:name1
memoryInfo:jsHeapSizeLimit:2181038082
session:cabSessionID:
sessionStartTime:
loginName:name1
memoryInfo:jsHeapSizeLimit:2181038080
session:cabSessionID:
sessionStartTime:
loginName:name2
memoryInfo:jsHeapSizeLimit:2181038080
session:cabSessionID:
sessionStartTime:
loginName:name3
memoryInfo:jsHeapSizeLimit:2181038084
session:cabSessionID:
sessionStartTime:
loginName:name4
memoryInfo:jsHeapSizeLimit:2181038080
session:cabSessionID:
sessionStartTime:
memoryInfo:jsHeapSizeLimit:2181038080
session:cabSessionID:
sessionStartTime:
loginName:name5
memoryInfo:jsHeapSizeLimit:2181038080
session:cabSessionID:
sessionStartTime:
loginName:name1
memoryInfo:jsHeapSizeLimit:2181038082
session:cabSessionID:
sessionStartTime:
loginName:name6
memoryInfo:jsHeapSizeLimit:2181038083
session:cabSessionID:
sessionStartTime:
This is repeated multiple times throughout the original output. I would like to search through this file and create another output text file that should have 1 line per user and look like the following:
loginName: memoryInfo:jsHeapSizeLimit:
The loginName and memoryInfo should be separated by a Tab space.
I want to exclude some names from this list.
This is what I have so far:
$ grep -e "^loginName\|^memoryInfo" FinalResults.txt | egrep -v 'name1|name2' | awk '$1!=p; {p=$1}' | paste -d"\t" - - > Test.txt
After removing the names, I am left with memoryInfo followed by memoryInfo.
How can I modify my script to have the output from this:
loginName:A memoryInfo:jsHeapSizeLimit: 1Gb
loginName:B memoryInfo:jsHeapSizeLimit: 2Gb
memoryInfo:jsHeapSizeLimit: 3Gb loginName:C
memoryInfo:jsHeapSizeLimit: 4Gb
loginName:A memoryInfo:jsHeapSizeLimit: 1Gb
loginName:B memoryInfo:jsHeapSizeLimit: 2Gb
loginName:C memoryInfo:jsHeapSizeLimit: 4Gb
Basically, it should be Name, memoryInfo in that pattern. If it is a memoryInfo followed by memoryInfo, I want the second one to be removed.

A,B,Cand1Gb,2Gb,3Gbfrom your input file?FinalResults.txtloginName:andmemoryInfo:lines that produces the wrong output with your script.loginName: memoryInfo:jsHeapSizeLimit. This doesn't match what you say it produces.FinalResults.txthas some entries without the loginName field which throws everything off. I posted a picture of the output on my original post so you see what I am talking about.