[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: sequential file mods...
- From: Ian Timshel <itschaotic yahoo ca>
- To: Red Hat Install <redhat-install-list redhat com>,@redhat.com, @redhat.com
- Subject: Re: sequential file mods...
- Date: Sun, 1 Dec 2002 02:14:50 -0600
On Friday 29 Nov 2002 3:19 am, Ian Timshel wrote:
> Hi all.
> I have a gazillion font path entries to edit in a config file on my Redhat
> 7.2 installation. All trazillion entries have to be prefixed with
> "file1=/fontpath" and the next entry needs to be "file2=/fontpath" there
> must be some way to do this with tools rather than manually.
awk 'BEGIN { i=1 } { print "file"i"=/fontpath"$0;i=i+1}' < your_config_file
> new_config_file
> I expect I
> should be using "grep" and regular expressions but I'm a way too wet
behind
> the ears to figure it out.... apparently.
The basic cantrips are fairly easy. The higher level magics require serious
study.
You must persevere with your studies and enlightenment will surely come.
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw ion le ac uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
--
=======================
Wow Nigel.
Working from a recipe is certainly a wonderful way to learn. I've found a
new respect for the term "cookbook". The script you offered wasn't quite
doing what I wanted and no doubt that process is a healthy one. ;^) Here
is what I ended up doing. With a little help from O'Reilly's "Linux in a
Nutshell" and the gawk manual at:
http://www.rotravelplus.com/~dragose/ad/gawk/gawk_toc.html
awk 'BEGIN { i=1 } { print "file"i"="$0;i=i+1}' source.txt >
modified_source.txt
I cut the content I wanted modified, out of the original config file and
saved it to the "source.txt" file. Then I applied awk to the contents of
"source.txt and cut and pasted the resulting "modified_source.txt" back
into the original config file.
Elegant... not.. I suppose, but awk was a little simpler to learn to
trouble shoot than some others, at least for me.
Your offering opened up a whole new world. Thank-you Nigel and company,
yet again.
Ian.
-----------------
http://www.amical.net - The Friendly IRC Network.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]