Skip to content
Advertisement

Shell script to replace all spaces in only the column headers to underscore in a csv file

I am trying to just replace the spaces in the column headers only with underscores(_).

this is my sample data

Input

JavaScript

Output

JavaScript

My sample code is something like this, sorry its very rough!

JavaScript

Advertisement

Answer

Unless your example is too simplistic, you just have to change all spaces to underscores in line 1

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement