thanks Tony.... but the bit that is mostly tricking me is going through the directory recursively to get to each file. I didn't mention the recursive thing in my original post - there are several hundred files in a directory tree ( a web site).
David. On Mon, Jun 20, 2005 at 10:56:12AM +1000, Tony Green wrote: > On 20/06/2005, at 10:51 AM, Tony Green wrote: > >perl -i -pe 's/foo.bar/bar.foo/g;s/\r/\n/g' <filename(s)> > > I was going to put some explanation in, but got to eager :-) > > OK let's break that down: > > perl - pretty obvious, runs the Perl interpreter > > -p - says to perl, 'for every line in the file, do this...' > -i - says to perl, 'don't create backup copies' > > -e - says 'run the next bit as if it's a script' > > s/foo.bar/bar.foo/g;s/\r/\n/g : This is the bit that does the work > > s// - the substitute command, The '/' are just separators > \r - a 'return' > \n - a 'newline > g - means 'global', ie for every ocurrance. > > So, put that together, and it means 'substitute every foo.bar with > bar.foo and every \r with \n' > > -- > Tony Green <[EMAIL PROTECTED]> > > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
