Re: Scripting problem (awk, maybe?)
- From: Zoltán Vad <zoltan.vad@xxxxxxxxx>
- Date: Sun, 9 Jul 2006 22:11:18 +0200
Hi Simon,
i hope this will help you.
awk '$1 ~ server { sub(from, to, $3); print $1,$2, $3 }' server=chp411
from=ITSC-ASAP to=ITSC-ASAP-CHE datafile
(this is one line command, be carefully, mailer probably will broke
the line ...)
Regards, Zoltan
2006/7/7, Green, Simon <Simon.Green@xxxxxxxxxxxxx>:
I want to make some changes to a configuration file. I think it ought to be
fairly simple with awk but I'm not very familiar with that.
The file is like...
server filename text-string
server filename text-string
...
"server" is a hostname.
"filename" is a file or filesystem name
"text-string" is one of several codes: a single string with no spaces.
The file is not in any particular order.
What I want is something like:
if server = server1
if text-string = stringA
replace it with stringB
...leaving the rest of the file unchanged.
I need to do this for multiple values of "server", but there's only one
value each for stringA and stringB.
There are multiple lines for each server, some all or none of which may
contain stringA.
stringB is actually stringA with a suffix, so anything testing for stringA
must be checking the whole word so as not to pick up existing occurrences of
stringB
e.g.
Old: chp411 /oracle/stage ITSC-ASAP
New chp411 /oracle/stage ITSC-ASAP-CHE
--
Simon Green
Altria ITSC Europe s.a.r.l.
AIX-L Archive at https://lists.princeton.edu/listserv/aix-l.html
<https://lists.princeton.edu/listserv/aix-l.html>
New to AIX? http://publib-b.boulder.ibm.com/redbooks.nsf/portals/UNIX
<http://publib-b.boulder.ibm.com/redbooks.nsf/portals/UNIX>
N.B. Unsolicited email from vendors will not be appreciated.
Please post all follow-ups to the list.
- References:
- Scripting problem (awk, maybe?)
- From: Green, Simon
- Scripting problem (awk, maybe?)
- Prev by Date: Re: IBM 3153 terminal - using 2 ports
- Next by Date: Re: Scripting problem (awk, maybe?)
- Previous by thread: Scripting problem (awk, maybe?)
- Next by thread: Re: Scripting problem (awk, maybe?)
- Index(es):
Relevant Pages
|
|