Awk Problem in Deleting Fields from Lines
Hi Everyone,
I am a newbie to this forum :). I am stuck with some awk programming. Basically, I have a huge file of data (1000*16384). My objective is that for each impair line (so line 1, 3, ...; lines starting with 1), I want to delete the entries that are smaller than say 0.1 . Furthermore, I also want to delete the entries in the pair lines (i.e. line 2, 4, ...) that occupy the index positions of the deleted entries of the previous line (so if entry/field i=5 was deleted in line 1 because it is smaller than 0.1, then I want the entry/field i=5 in line 2 to be also deleted regardless of its value). Here is an attempt awk '{ for (j=1; j<=NR; j=j+2) { for (i=1; i<=NF; i++) { { if ($i<0.1) { sub($i,"") ; c = i ; NR == k} }; NR==k+1 ; sub($c,"") }} } } } print }' dataFile1.output > dataFile2.output thanks in advance |
Please, can you post an example of input and the related output you want to obtain? It would be far more clear what the problem is. Anyway, I see your code doesn't take advantage of the awk power. The loop:
Code:
for (j=1; j<=NR; j=j+2) ... Code:
NR % 2 == 0 { |
Thanks colucix for your quick reply.
Yes, here is the sort of input / output I mean input 0.20 0.30 0.05 0.22 0.12 0.07 0.08 0.14... 20.8 20.6 20.4 20.2 20.0 19.8 19.6 19.4 0.16 0.25 0.31 0.02 0.19 0.04 0.28 0.12 20.8 20.6 20.4 20.2 20.0 19.8 19.6 19.4 ... output 0.20 0.30 0.22 0.12 0.14... 20.8 20.6 20.2 20.0 19.4 0.16 0.25 0.31 0.19 0.28 0.12 20.8 20.6 20.4 20.0 19.6 19.4 ... |
Good. I would try something like this: odd lines: print the fields > 0.1 and store (remember) the index of the printed fields; even lines: print only the fields in the list of indexes stored above. Translated in awk:
Code:
NR % 2 == 1 { |
Thanks a lot colucix, it worked!
|
All times are GMT -5. The time now is 12:38 AM. |