head -1 file.txt | perl -F, -lane 'print join(",",@F);' #### head -1 file.txt | sed -e 's/$/x/' | perl -F, -lane 'print join(",",@F[0..$#F-1]);'