How to insert two lines for every data frame using awk? -



How to insert two lines for every data frame using awk? -

i have repeating info follows

.... 4 4 4 66 79 169 150 0 40928 40938 40923 40921 40789 40000 40498 5 4 3 16 22 247 0 40168 40911 40944 40205 40000 40562 6 4 4 17 154 93 309 0 40930 40919 40903 40917 40852 40000 40419 7 3 2 233 311 0 40936 40932 40874 40000 40807 ....

this info made of 115 info blocks, , each info block have 4000 lines format. here, hope set 2 new lines (number of line per info block = 4000 , empty line) @ begining of each info blocks, looks

4000 1 4 4 244 263 704 952 0 40936 40930 40934 40921 40820 40000 40570 2 4 4 215 172 305 33 0 40945 40942 40937 40580 40687 40000 40410 3 4 4 344 279 377 1945 0 40933 40915 40907 40921 40839 40000 40437 4 4 4 66 79 169 150 0 40928 40938 40923 40921 40789 40000 40498 ... 3999 2 2 4079 4081 0 40873 40873 40746 40000 40634 4000 1 1 4080 0 40873 40923 40000 40345 4000 1 4 4 244 263 704 952 0 40936 40930 40934 40921 40820 40000 40570 2 4 4 215 172 305 33 0 40945 40942 40937 40580 40687 40000 40410 3 4 4 344 279 377 1945 0 40933 40915 40907 40921 40839 40000 40437 4 4 4 66 79 169 150 0 40928 40938 40923 40921 40789 40000 40498 ...

can awk or other unix command?

a simple 1 liner using awk can purpose.

awk 'nr%4000==1{print "4000\n"} {print$0}' file

what does.

print $0 prints every line. nr%4000==1 selects 4000th line. when occures prints 4000 , newline \n, 2 new lines.

nr number of records, effectivly number of lines reads far.

simple test.

inserts 4000 @ 5th line

awk 'nr%5==1{print "4000\n"} {print$0}'

output:

4000 1 2 3 4 5 4000 6 7 8 9 10 4000 11 12 13 14 15 4000 16 17 18 19 20 4000

awk insert lines

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -