From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,cfca9efd49c50e97,start X-Google-Attributes: gidfee84,public From: mjeffery@cix.compulink.co.uk ("Mark Jeffery") Subject: Re: (no subject) Date: 1995/10/30 Message-ID: #1/1 X-Deja-AN: 118391773 references: <1995Oct24.201837.21442@newton.ccs.tuns.ca> organization: Compulink Information eXchange x-news-software: Ameol32 newsgroups: comp.unix.osf.osf1 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