I have a tab separated file contain 19 columns, some of these columns contain comma at the end. I want to removed these comma from all columns if it is at the end.Example:c1   c2   c3   c4   c5  re,  f,f   d,f,  gf   mkdf   df,  df   dl,  df,The result should be and saved in the same filec1   c2    c3    c4   c5  re   f,f   d,f   gf   mkdf   df    df    dl   df
Remove comma from columns in a file if it is at the end
text processing;perl;columns
You can do this:perl -i -pe 's/,(\t|$)/$1/g' fileThat will remove any commas followed by a space, a tab or a newline. For other field delimiters, for example :, use:perl -i -F: -lane 's/,$// for @F; print join :,@F' fileThese commands will change the original file, remove the -i to test it first. 