Skip to navigation

Use sed to remove the first column in a comma separated file (csv)

Here’s how:

sed -i 's/[^,]*,//' file.csv

Note the [^,]* bit, which matches everything that is not a comma. Don’t use .*, because this will greedily match commas, too. (Usually, cut is useful for these sort of things, but cut cannot readily replace the file in place.)

Comments are closed.