Awk selective printing

Hi,

i need help to print number from different field

INPUT:

Student1 10 20
Student2 30 40
Student3 50 60
Student4 70 80

Desired Output:
1 20-30
2 40-50
3 60-70

Thank you!

>:cat Stud
Student1 10 20
Student2 30 40
Student3 50 60
Student4 70 80

>:more Stud | nawk '{print substr($0,8) $2"-"$3}'
1 10-20
2 30-40
3 50-60
4 70-80
>:
1 Like
awk '{print $2,$3"-"$4}' FS="nt| "
1 Like

Hi 47Shailesh and Yinyuemi,

Thanks for your help. But still i am not able to get the desired output. It doesn't matter even if the output is not numbered.

20-30
40-50
60-70
awk 'NR==1{start=$NF;next} {print ++i,start"-"$2;start=$NF}' infile
1 Like

Thanks!