I am trying to just replace the spaces in the column headers only with underscores(_).
this is my sample data
Input
"SFDC Account ID",Owner,"Coverage Fiscal Year","HQ Duns","Account Name",DBA,"Legacy LID","HPI LID",Address,City,State,"POST Qual","POST/Non POST","Program Level","Buying Group","Previous Coverage Code","Previous Region","Previous PBM/Rep","Previous Manager","Qualified Status Last Updated","Qualified Supplies Status ","Qualified Print Status","PageWide Reseller","Coverage Code",Region,Manager,"Supplies Rep (Abc/xyz)","Supplies Rep Role","Supplies Rep Email","Hardware Rep (abc/xyz)","Hardware Rep Role","Hardware Rep Email",Status,"Acquired by/Merged Account",Category,"Proposed Rep","Proposed Coverage Code","Latest Quarterly Sales","Latest Quarterly Quota",xyz_Market_Share_Ink_C,xyz_Market_Share_Toner__c,xyz_Market_Share_Toner_Color__c,Total_xyz_Toner_Share__c,Share_Reporting_Periods__c 001U000000,005U00000,FY2020-2H,5454,"T & G xyz INC xyz TGI OFFICE xyz","T & G xyz INC DBA zyz OFFICE xyz",,10312198,"143 xyz xx.",BROOKLYN,NY,POST,POST,Premier,,A,East,"Steve xyz","Preston xyz",2020/05/21,Qualified,Qualified,Yes,A,East,"Preston xyz","AJ xyz","xyz Partner Business Manager",xyz@hp.com,"xyz Macaluso",,,Active,,"xyz > 80%",,,0,0,100,,,99.05482041587,"Q419 & Q120"
Output
"SFDC_Account_ID",Owner,"Coverage_Fiscal_Year","HQ_Duns","Account_Name",DBA,"Legacy_LID","HPI_LID",Address,City,State,"POST_Qual","POST/Non_POST","Program_Level","Buying_Group","Previous_Coverage_Code","Previous_Region","Previous_PBM/Rep","Previous_Manager","Qualified_Status_Last_Updated","Qualified_Supplies_Status_","Qualified_Print_Status","PageWide_Reseller","Coverage_Code",Region,Manager,"Supplies_Rep_(Abc/xyz)","Supplies_Rep_Role","Supplies_Rep_Email","Hardware_Rep_(abc/xyz)","Hardware_Rep_Role","Hardware_Rep_Email",Status,"Acquired_by/Merged_Account",Category,"Proposed_Rep","Proposed_Coverage_Code","Latest_Quarterly_Sales","Latest_Quarterly_Quota",xyz_Market_Share_Ink_C,xyz_Market_Share_Toner__c,xyz_Market_Share_Toner_Color__c,Total_xyz_Toner_Share__c,Share_Reporting_Periods__c 001U000000,005U00000,FY2020-2H,5454,"T & G xyz INC xyz TGI OFFICE xyz","T & G xyz INC DBA zyz OFFICE xyz",,10312198,"143 xyz xx.",BROOKLYN,NY,POST,POST,Premier,,A,East,"Steve xyz","Preston xyz",2020/05/21,Qualified,Qualified,Yes,A,East,"Preston xyz","AJ xyz","xyz Partner Business Manager",xyz@hp.com,"xyz Macaluso",,,Active,,"xyz > 80%",,,0,0,100,,,99.05482041587,"Q419 & Q120"
My sample code is something like this, sorry its very rough!
tee '/path/xyz.csv' | REPLACE(row1, ' ', '_')
Advertisement
Answer
Unless your example is too simplistic, you just have to change all spaces to underscores in line 1
sed '1s/ /_/g' yourinputfile