Click to See Complete Forum and Search --> : Replace?
Sastraxi
12-08-2002, 11:08 AM
(bash)
Is there something that can replace a sequence of characters in a file with a different sequence? In this case, I want to change all of the instances of "1280x960" to "800x600" in my XF86Config-4 file. Thanks in advance.
AdaHacker
12-08-2002, 11:22 AM
You can use sed or awk for that.
You can also just open the file in vi, and (in command mode) type
:% s/1280x960/800x600/g
Sastraxi
12-08-2002, 11:43 AM
How would I do this in a shell script? Would it be the same syntax?
My main purpose is to create a script "gamex", and another called "appx". When I call "gamex", I replace the values 1280x960 with 800x600 and call startx. When I call "appx", I replace the values in the config file from 800x600 to 1280x960 and call startx. So this is what I have for both:#!/bin/bash
???
startx
Sastraxi
12-08-2002, 11:48 AM
Alright, just did a quick search. This is what I have:#!/bin/bash
#/usr/bin/gamex
sed ‘s/1280x960/800x600/g’ /etc/X11/XF86Config-4
startx