The sed command can be handy for small tasks. You could use a modification of the command below: #> sed 's/\(.\{2\}\)/&,/; s/\(.\{6\}\)/&,/' file_name Just change the number inside the brackets where you want the comma to go... If you have a 3 line file with "1234567890" on each line the output would be: 12,345,67890 12,345,67890 12,345,67890