To study the formation of the [OI] lines - i.e., 5577 A (the green line), 6300 A and 6364 A (the two red lines) - in the coma of comets and to determine the parent species of the oxygen atoms using the green to red-doublet emission intensity ratio (G/R ratio) and the lines velocity widths. We acquired at the ESO VLT high-resolution spectroscopic observations of comets C/2002 T7 (LINEAR), 73P-C/Schwassmann-Wachmann 3, 8P/Tuttle, and, 103P/Hartley 2 when they were close to the Earth (< 0.6 au). Using the observed spectra, we determined the intensities and the widths of the three [OI] lines. We have spatially extracted the spectra in order to achieve the best possible resolution of about 1-2, i.e., nucleocentric projected distances of 100 to 400 km depending on the geocentric distance of the comet. We have decontaminated the [OI] green line from C2 lines blends. It is found that the observed G/R ratio on all four comets varies as a function of nucleocentric projected distance. This is mainly due to the collisional quenching of O(1S) and O(1D) by water molecules in the inner coma. The observed green emission line width is about 2.5 km/s and decreases as the distance from the nucleus increases which can be explained by the varying contribution of CO2 to the O(1S) production in the innermost coma. The photodissociation of CO2 molecules seems to produce O(1S) closer to the nucleus while the water molecule forms all the O(1S) and O(1D) atoms beyond 1000 km. Thus we conclude that the main parent species producing O(1S) and O(1D) in the inner coma is not always the same. The observations have been interpreted in the framework of the coupled-chemistry-emission model of Bhardwaj & Raghuram (2012) and the upper limits of CO2 relative abundances are derived from the observed G/R ratios. Measuring the [OI] lines could indeed provide a new way to determine the CO2 relative abundance in comets.