I have a tab-separated file that looks like this:
NZ_CP023599.1 WP_003911075.1 302845 305406
NZ_CP023599.1 WP_003898428.1 471171 472583
NZ_CP023599.1 WP_003402248.1 534387 535157
NZ_CP023599.1 WP_003402301.1 552556 553950
NZ_CP023599.1 WP_003402318.1 558837 559697
I need to subtract the number in 4th column of each row from the number in 3rd column of the next line, and then print the difference in the next line as a 5th column.
The output would look like this:
NZ_CP023599.1 WP_003911075.1 302845 305406
NZ_CP023599.1 WP_003898428.1 471171 472583 165765
NZ_CP023599.1 WP_003402248.1 534387 535157 61804
NZ_CP023599.1 WP_003402301.1 552556 553950 17399
NZ_CP023599.1 WP_003402318.1 558837 559697 4887
How do I go about this using awk?