unix header clarification

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

unix header clarification

vamsi
I have a single file consists of 3 columns .The Number of columns are fixed in file but the order of columns may vary as below.

empid,ename,sal
1,vamsi,10
2,sam,20
3,ram,30

or

ename,sal,empid
vamsi,10,1
sam,20,2
ram,30,3

or

empid,sal,ename
1,10,vamsi
2,20,sam
3,30,ram

etc

Required o/p:

empid,ename,sal
1,vamsi,10
2,sam,20
3,ram,30

Irrespective of order of columns defined in input i need output file in the
following order empid,ename,sal

I am not sure how to fetch the columns based on header information but aware of cut command