awk '{ print (FNR-1) % 3 ? "H" : "O", $0 }' file
This uses awk to prefix the current line with an H or an O depending on whether the current line's line number is a multiple of three or not.
If you want a tab character as a delimiter between the new column and the others, make sure that OFS has the value \t:
awk -v OFS='\t' '{ print (FNR-1) % 3 ? "H" : "O", $0 }' file
Using GNU sed specifically and assuming that you want the new column separated from the others with a tab character:
sed -e '1~3 s/^/O\t/' -e '1~3! s/^/H\t/' file
The first expression adds O followed by a tab character to every third line starting at line 1. The second adds H and a tab character to all lines that are not every third line starting at the line 1.
This requires GNU sed due to the following two non-standard features:
- The address
n~mmeans "everym:th line, starting at linen". - The character sequence
\tis expanded to a literal tab character.
Using other tools:
yes 'O H H' | tr ' ' '\n' | head -n "$( wc -l <file )" | paste - file
This produces a steady stream of O, H, H (repeating) on separate lines using yes and tr. This stream is cut short with head to match the number of lines in our file (this is calculated using wc -l). The O:s and H:s are then inserted to the left of the rest of the file's contents using paste, with a tab character as delimiter.