I wanna print field (from 4th to the last field) as new line for each by inserting increasing arithmetically variable (from 5 to 25) after 3rd field in the text file.
Data format:
01.01.1995 01:00 1.0 1.2 2.5 3 4.8 5.2
31.01.1995 23.00 31.0 2.3 7.5 8.7 8.7 10
.
awk '{for(i=5;i<=25;i+=5) print $1,$2,$3,i,$(3+i/5)}'
Desired output:
01.01.1995 01.00 1.0 5 1.2
01.01.1995 01.00 1.0 10 2.5
01.01.1995 01.00 1.0 15 3
01.01.1995 01.00 1.0 20 4.8
01.01.1995 01.00 1.0 25 5.2
31.01.1995 23.00 31.0 5 2.3
31.01.1995 23.00 31.0 10 7.5
31.01.1995 23.00 31.0 15 8.7
31.01.1995 23.00 31.0 20 8.7
31.01.1995 23.00 31.0 25 10
Desired output 2:
01.01.1995 01.00 1.0 5 5.2
01.01.1995 01.00 1.0 10 4.8
01.01.1995 01.00 1.0 15 3
01.01.1995 01.00 1.0 20 2.5
01.01.1995 01.00 1.0 25 1.2
31.01.1995 23.00 31.0 5 10
31.01.1995 23.00 31.0 10 8.7
31.01.1995 23.00 31.0 15 8.7
31.01.1995 23.00 31.0 20 7.5
31.01.1995 23.00 31.0 25 2.3
So the first three field should be same.
There are a few obvious ways to do the arithmetic - for example
or
To reverse the order of the final field, start at
NF
and count down e.g.