I have a data file named File-1
. I have to match a pattern DATA_POINTS
, and then after skipping one line I want to print 6th column of the following lines.
File-1
example:here ! some other data exist but all of them are totally different from the below data! In simple words following data is completely unique. DATA_POINTS 12 0.0000000000 0.0000000000 0.0000000000 20 ! A 0.5000000000 0.5000000000 0.0000000000 20 ! B 0.7500000000 0.5000000000 0.2500000000 20 ! C 0.7500000000 0.3750000000 0.3750000000 20 ! D 0.0000000000 0.0000000000 0.0000000000 20 ! E 0.5000000000 0.5000000000 0.5000000000 20 ! F 0.6250000000 0.6250000000 0.2500000000 20 ! U 0.7500000000 0.5000000000 0.2500000000 20 ! W 0.5000000000 0.5000000000 0.5000000000 20 ! L 0.7500000000 0.3750000000 0.3750000000 20 ! K 0.6250000000 0.6250000000 0.2500000000 20 ! U 0.5000000000 0.5000000000 0.0000000000 20 ! X
- Desired output
S1 = A S2 = B S3 = C S4 = D S5 = E S6 = F S7 = U S8 = W S9 = L S10= K S11= U S12= X
The pattern DATA_POINTS
does not repeat in the file, and an exact match is desired.
Nearest Solution
I got this command from another qsn. this is working if the 6th column in a same row of pattern
awk '/DATA_POINTS/{i==0 ; i++; getline; print "S"i"=", $6}' File-1