From: kazaam Date: 2007-08-27T00:35:05+09:00 Subject: Re: Finding one certain line in a file is easy but how to look for headlines and something just under this certain headline? thx for your help, I solved it now this way (I know pretty messy) but it works fine: system('cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak') xorgbak = File.open('/etc/X11/xorg.conf.bak') xorg = File.open('/etc/X11/xorg.conf','w') drifound = false compofound=false while line = xorgbak.gets driverflag = true if /Section "Device"/.match(line) driverflag = false if driverflag && line.gsub!(/(Driver\s+)"(.*)"/, '\1"fglrx"') (driflag = true & drifound = true) if /Section "DRI"/.match(line) driflag = false if driflag && line.gsub!(/(Mode\s+).*/, '\10666') (compoflag = true & compofound = true) if /Section "Extensions"/.match(line) compoflag = false if compoflag && line.gsub!(/(Option\s+)"(.*)"/, '\1"Composite" "Disable"') xorg.puts line end xorgbak.close xorg.close xorg = File.open('/etc/X11/xorg.conf',"a") if not drifound xorg.puts'' xorg.puts'Section "DRI"' xorg.puts' Mode 0666' xorg.puts'EndSection' end if not compofound xorg.puts'' xorg.puts'Section "Extensions"' xorg.puts' Option "Composite" "Disable"' xorg.puts'EndSection' end xorg.close -- kazaam