Re: sed question

From: Bill Thompson (bill.thompson@GOODYEAR.COM)
Date: Wed Jul 09 2003 - 06:52:14 EDT


John,

Here's *one* way to do it:

- - - - - snip - - - - -
#!/bin/sh

vi $1 >/dev/null 2>&1 <<END_OF_VI
1G945|c6lGORDON^[:wq!
END_OF_VI
- - - - - snip - - - - -

Let me break down the line after vi:

1G945|c6lGORDON^[:wq!

1G go to the first line
945| go to the 945th character on the line
c6l change the next 6 characters
GORDON with the string "GORDON"
^[ this is one character formed by pressing CTRL-V followed by ESC
:wq! write, quit

Not sed or awk, but it works.

(Note - vi won't work if any line in your file is greater more than 2048
characters long (but vim will))

Bill Thompson
Sr UNIX Systems Administrator
The Goodyear Tire & Rubber Co.

Contains Confidential and/or Proprietary Information
May Not Be Copied or Disseminated Without Express Consent of The Goodyear
Tire & Rubber Company.

AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2

----- Original Message -----
From: "John Dunn" <john.dunn@SEFAS.CO.UK>
Newsgroups: bit.listserv.aix-l
To: <aix-l@Princeton.EDU>
Sent: Wednesday, July 09, 2003 4:02 AM
Subject: sed question

> I need a shell script that will change characters 945-950 in the first
line
> only of a file to a specified string, i.e "GORDON". I will not know what
> the original value is. Can I do this with sed, if so, how, or do I need
to
> use awk?
> J



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:00 EDT