The near and midinfrared spectra of 1-octanol (and 2-octanol) have been measured along the liquid-gas coexistence curve from room temperature up to the critical point and in the supercritical domain along the isotherm T=385 degrees C (and T=365 degrees C) above the critical point of both 1-octanol and 2-octanol for pressure ranging from 0.5 up to 15 MPa. The density values of SC 1- and 2-octanol have been estimated by analysing the near infrared (NIR) spectra in the 3nu(a)(CH) region. A quantitative analysis of the absorption band associated with the OH stretching vibration [nu(OH)] and its first and second overtones [2nu(OH) and 3nu(OH)] was carried out in order to estimate the percentage of "free" OH groups in both alcohols in the whole thermodynamic domain investigated here. Very consistent results have been obtained from the independent analysis of these three different absorption bands which gave us a good confidence in the degree of hydrogen bonding reported here for 1- and 2-octanol. Thus, the percentage of free OH groups which is around 5% in liquid 1-octanol under ambient conditions strongly increase up to 70%-80% at a temperature of about 340 degrees C. Then, in the supercritical domain, upon a decrease of the density from 0.4 to 0.1 g cm(-3), the fraction of free hydroxyl groups is nearly constant presenting a plateaulike regime around 80%. As the density decreases again, this plateau regime is followed by a further increase of X(nb) which reaches a value of 96% for the system in the gaseous phase (0.01 g cm(-3); P=0.45 MPa). Finally, it comes out from this study that the percentage of free OH groups is always greater in 2-octanol than in 1-octanol at the same density.