Insert carriage return on the 10th char position of each line

Hi experts,

Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return.

Example:

>cat test.txt
testingline
dummystring
samplesample
teststringline

Expected output should be..

testinglin
  e
dummystrin
  g
samplesamp
  le
teststring
  line

i am currently using the "cat test.txt| while read line and then some cut commands" but im thinking of other commands that can produce the same output.

Thank u in advance!

I presume you mean linefeed instead of carriage return. You could try sed:

sed 's/./\
  &/11' infile
1 Like

Thanks Scrutinizer!!