Skip to navigation

Archive for August, 2010

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

Monday, August 2nd, 2010

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.)