I got a requirement i have a input file which am getting from different source,Now i want to add extra 3 columns to this file like BASE,ACTUAL and DATE.
Input File Looks like
QUAL CHGE TYP LAW COM1 COM2
A 1 X SED HO ASE
B 3 Z CDE SE TOE
Ouptut file i need like this
BASE ACTUAL DATE QUAL CHGE TYP LAW COM1 COM2
PD DV 09/11/2015 A 1 X SED HO ASE
PD DV 09/11/2015 B 3 Z CDE SE TOE
Please help me out here,Am new to shell scripting.
Yes it is working.But my requirement is to write the output in CSV file.I can able to write that in CSV file using this command ">" Is there a way i can write each field in each column of CSV file
Attached the output file which am getting now for your reference.
Your welcome Ahmad. You can use the following command to get output in a .csv file first.
awk 'NR==1{$0="BASE ACTUAL DATE" "\t\t" $0} NR>1{$0="PD DV 09/11/2015" "\t\t" $0} 1' change_fields > sample.csv
Now open .csv file and perform following steps.
Go to Menu's DATA option ---> Select TEXT to Columns option---> Select Delimited option--->Then select TAB + space --->Give a Next in wizard--->Click DONE
Here I am considering that your fields doesn't have space in themselves
else it will segregate them too.
I can't see three columns added to your sample file, I see three words separated by spaces added to your first column.
A .csv file is a text file with columns separated by commas, semicolons or similar, readable immediately by data bases or spread sheets. To achieve this, try