Hi Team
I have file as below
empno,ename,sal
123,smith,1000
124,adams,2000
Required output: Using AWK
empno,ename,sal,deptno
123,smith,1000
124,adams,2000
Thanks,
Murali
Hi Team
I have file as below
empno,ename,sal
123,smith,1000
124,adams,2000
Required output: Using AWK
empno,ename,sal,deptno
123,smith,1000
124,adams,2000
Thanks,
Murali
Hello bmk,
You could try following and let me know if this helps you.
awk 'NR==1{print $0",deptno";next} 1' Input_file
Thanks,
R. Singh
Thanks it's working. please let me know "next" keyword why it is required.
Hello bmk,
awk 'NR==1{ ##### When first line is getting read.
print $0",deptno"; ##### If above condition is TRUE and then print the first line with "deptno".
next} ##### next keyword is awk's built in keyword which helps us to skip all next statements.
1' Input_file ##### mentioning 1 here for making condition TRUE, because awk works on condition and then action method, so here we are making condition TRUE and not giving any action so default action will happen which is printing the line.
Thanks,
R. Singh
Try also
awk 'NR==1{$0=$0 ",DeptNo"}1' file
Working fine. Thanks Rudic and Singh