Bear in mind that there are many flavours of comma-separated-value file. Since you didn't specify one, I'll assume RFC-4180 format, in UTF-8 encoding, and the TSV to be the same but using tabs instead of commas.
The naive approach would be to simply replace every tab with a comma:
tr '\t' ,
This falls down if any of the values already contain a comma, or if any contain a quoted tab. You'll need to minimally parse the file, to maintain quoting. Instead of hand-rolling such a parser, it's simpler, clearer and more flexible to use one already written, such as Text::CSV
for Perl:
#!/usr/bin/perl -w use Text::CSV; my $tsv = Text::CSV->new({ sep_char => "\t", auto_diag => 2 }); my $csv = Text::CSV->new(); while (my $row = $tsv->getline(*ARGV)) { $csv->print(STDOUT, $row) or die $csv->error_diag(); print $/; } $csv->error_diag() unless $tsv->eof;