From: mjeffery@cix.compulink.co.uk ("Mark Jeffery")
Subject: Re: (no subject)
Date: 1995/10/30 [thread overview]
Message-ID: <DHA3rr.BL1@cix.compulink.co.uk> (raw)
In-Reply-To: 1995Oct24.201837.21442@newton.ccs.tuns.ca
Hi,
You should use sed or awk. You can give sed a command to edit a file. For
example the following will substitute this for that in a file fred.txt,
and create newfred.txt as the modified file.
# sed -e 's/this/that/g' fred.txt > newfred.txt
the /g at the end means that the substitute will occur more than once in
a line (do a man sed for more details).
If you need to substitute a special character, you will need to use the \
character before it. For example the following command will substitute /
for \ (useful for moving from UNIX to DOS file specifications!)
# sed -e 's/\//\\/g' fred.csh > fred.bat
The first \/ is the '/' character to replace it, and the \\ is the '\'
character that replaces the '/'. This can be a bit difficult to see, but
it is easy if you practice.
A very useful sequence to use is ^ to signify the beginning of a line, $
the end. The following line will replace './' with 'cp '
# sed -e 's/^\.\//cp ' fred.txt >newfred.txt
An * is a useful wildcard (There are loads more in the manual pages). The
following example will remove from the occurence of the word 'string' to
the end of a line.
# sed -e 's/string*$//' fred.txt >newfred.txt
I don't have a UNIX machine to hand at the moment, so I am sure to have
got something wrong. The key thing is to try things out. You will soon
realise who powerful regular expressions are.
Mark Jeffery
^I ^a^m ^a ^c^o^n^t^r^o^l ^f^r^e^a^k
next prev parent reply other threads:[~1995-10-30 5:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1995Oct24.201837.21442@newton.ccs.tuns.ca>
1995-10-25 4:00 ` (no subject) Mark Charette
1995-10-25 4:00 ` Substituting Characters ( ' with '' ) and ( & with and ) Parker Barrington
1995-10-27 4:00 ` Stefan Krieghoff
1995-10-30 5:00 ` "Mark Jeffery" [this message]
1999-11-11 5:00 (no subject) Fredrik Lind
-- strict thread matches above, loose matches on Subject: below --
1997-10-29 5:00 (No Subject) Sergey Yu. Bobrovnikov
1997-11-12 5:00 ` David Stephens
1997-07-02 4:00 (no subject) administration
1997-05-03 4:00 shaila
1996-03-27 5:00 G Barber
[not found] <4e5dla$7pq@pubxfer2.news.psi.net>
1996-01-25 5:00 ` Seung-Jo Baek.
1996-01-22 5:00 Chris D.J. Waschke
1996-01-17 5:00 Casey Kolehmainen
1996-01-06 5:00 Darren Leonard
1995-12-14 5:00 Michel Jouvin
1995-11-09 5:00 Marcel philippe DCS 26-75 (13-72 40)
1995-10-27 4:00 Jeff G. Micono 9426
1995-10-25 4:00 Tonyi
1995-10-03 4:00 Vincenzo Martorana
1995-10-06 4:00 ` Jim Lawton
1995-08-04 4:00 Michael Gelbmann
1995-07-28 4:00 Christophe MATHIEU
1995-07-22 4:00 Bernd Metzger
1995-07-22 4:00 Bernd Metzger
1995-07-18 4:00 Christophe MATHIEU
1995-07-12 4:00 Bassirou Bah
1995-07-07 4:00 Istvan Pecsenyanszky
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox