Logic needed

input :

employee_id, salary
-------------------
10,          1000
20,          2000
30,          3000
40,          5000

output:

employee_id, salary, next_row_salary
------------------------------------
10,          1000,       2000
20,          2000,       3000
30,          3000,       5000
40,          5000,       Null

Please gimme the command to get this output

Hi

$ awk '{ if(x){print x", "$2;}x=$0;}END{print x",           NULL"}' FS="," file
10,          1000,           2000
20,          2000,           3000
30,          3000,           5000
40,          5000,           NULL

Guru.

Thanks Guru..It worked..Could you please explain that if statement

Hi
The idea is to print the last line along with the second column of the current line. To get the last line, we store the current line in x which in turn becomes the last line in the next iteration.

Guru.