bash - How do I change the column name of a CSV file? -
i have multiple csv files looks this:
col1,col2 val1,val2 i want change col2 in each file column2. how edit csv file's column name bash?
use sed.
sed -i '1s/col2/column2/' file.csv
for multiple files, can use loop:
for f in file1.csv file2.csv file3.csv sed -i '1s/col2/column2/' $f done or can use find execute sed:
find . -name *.csv -exec sed -i '1s/col2/column2/' {} \;
this replace col2 in csvs in current directory , sub-directories column2.
Comments
Post a Comment