Re: Modifying strings in a file.

From: Ron Schwingel (rschwing@NDSLTD.COM)
Date: Wed Aug 28 2002 - 15:56:50 EDT


The following won't work because it will uncomment lines I don't want
uncommented.

cat file|sed "s/^#//g"

The below won't work because I will not always know what word2 word3 word4
is.

sed -e 's/^#Word1 Word2 Word3 Word4/Word1 Word2 Word3 Word4/' file >
/tmp/file

Ron Schwingel
Technical Support

NDS Solutions
303.755.4411(phone)
303.755.4545(fax)
rschwing@ndsltd.com

 -----Original Message-----
From: Bill Verzal [mailto:Bill_Verzal@BCBSIL.COM]
Sent: Wednesday, August 28, 2002 1:21 PM
To: aix-l@Princeton.EDU
Subject: Re: Modifying strings in a file.

 cat file|sed "s/^#//g"
----------------------------------------------------------------------------
----------------------------

Bill Verzal
Technical Consultant
Forbes Technical Consulting
(312) 653-3684
bill_verzal@bcbsil.com
MailStop: 27.201C

                    Ron Schwingel
                    <rschwing@NDSL To: aix-l@Princeton.EDU
                    TD.COM> cc:
                    Sent by: IBM Subject: Re: Modifying strings
in a file.
                    AIX Discussion
                    List
                    <aix-l@Princet
                    on.EDU>

                    08/28/2002
                    01:40 PM
                    Please respond
                    to IBM AIX
                    Discussion
                    List

Thanks for your reply Bill.

However, I find I wasn't very precise. I need to know how to find a string
associated
with one or more lines in a file and replace it with another string while
retaining everything
else in that line.

For example:

        Find string: #Word1 Word2 Word3 Word4

        Replace with: Word1 Word2 Word3 Word4

I am uncommenting a line in a file. So, I need to change the first word
with
another,
while retaining the rest of the line.

Ron Schwingel
Technical Support

NDS Solutions
303.755.4411(phone)
303.755.4545(fax)
rschwing@ndsltd.com

 -----Original Message-----
From: Bill Verzal [mailto:Bill_Verzal@BCBSIL.COM]
Sent: Wednesday, August 28, 2002 11:42 AM
To: aix-l@Princeton.EDU
Subject: Re: Modifying strings in a file.

sed "s/A//g" wil replace all "A" characters with nothing. Hence delete
them.

BV
----------------------------------------------------------------------------

----------------------------

Bill Verzal
Technical Consultant
Forbes Technical Consulting
(312) 653-3684
bill_verzal@bcbsil.com
MailStop: 27.201C

                    Ron Schwingel
                    <rschwing@NDSL To: aix-l@Princeton.EDU
                    TD.COM> cc:
                    Sent by: IBM Subject: Modifying strings in
a
file.
                    AIX Discussion
                    List
                    <aix-l@Princet
                    on.EDU>

                    08/28/2002
                    12:13 PM
                    Please respond
                    to IBM AIX
                    Discussion
                    List

Does anyone know of a way, using "sed" or "awk", to delete a single
character
or characters from a line within a file.

Thanks,

Ron Schwingel
Technical Support

NDS Solutions
303.755.4411(phone)
303.755.4545(fax)
rschwing@ndsltd.com



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:10 EDT