I have requirement where I need to construct a file based on control file. The first row of my source file contains column names. The control file contains the columns which I need to output into a file
Source file:
ename|eid|emanger|esal|city|deptid|deptname
peter|10|larry|$2000|melbourne|20|electronics
shaun|11|Peter|$1000|sydney|20|electronics
Control file:
ename
eid
esal
ecity
o/p -- we need output only the columns which are there in the control file and the column order should be the same as in the control file.
Sample Output:
ename|eid|esal|ecity
peter|10|$2000|melbourne
shaun|11|$1000|sydney
-F="\|"
as awk arguement – Archemar Nov 15 '15 at 14:18city
, but your control file specifiesecity
. – G-Man Says 'Reinstate Monica' Nov 15 '15 at 19:42