From: Sebastian Hungerecker Date: 2007-08-26T21:31:03+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? kazaam wrote: > Hi, > I'm writing a little script for installing ati-drivers on linux machines > but I have a little problem. I need to change the /etc/X11/xorg.conf file > for this. For what you're trying to do, you could just read the file in as a string, use String#sub on it and write it to file again, but here is something a little more fun (for me to write anyway): http://pastie.caboo.se/91056 Usage: xconf=XConf.new "/etc/X11/xorg.conf" xconf["Device"]["Driver"]='"fglrx"' xconf.write #This will backup the old config to /etc/X11/xorg.conf.old #or xconf.write "new_config" The new config won't contain comments. I just quickly hacked this up, so this isn't thoroughly tested and may contain bugs (the above example works as it should, though, I tested that much). There's obviously some room for improvement here, but for the beginning this seems decent enough. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826