bash - Remove Previouse Instances in a Pattern -


i have large output file (~25000 lines) of alphanumeric text has @ minimum 4 instances of each step possibly 5th followed data. want output last iteration of each step text file , delete others how this?

example: each iteration should on own line

input file: data.dat

1 step1.1  1 step1.2  1 step1.3  1 step1.4  2 step2.1  2 step2.2   2 step2.3  2 step2.4  2 step2.5 

desired output:

1 step1.4 2 step2.5 

  1. this may destroy order: remember recent line each key:

    awk '{line[$1] = $0} end {for (key in line) print line[key]}' data.dat 
  2. reverse file , print first time see key, re-reverse output (this "famous" awk idiom)

    tac data.dat | awk '!seen[$1]++' | tac 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -