Skip to main content
1 of 3
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
sed 's/^i/o/;H;1h;$!d;x;q' <infile >>infile

If the file is small enough to fit into memory, then the above should work. I can't think of any reason you might have an encoding problem unless your sed is buggy. A sane sed should handle any valid character encoding you might care to throw at it.

mikeserv
  • 59.4k
  • 10
  • 122
  • 242