Release

Stephan Kramer stephan.kramer at imperial.ac.uk
Sat Sep 29 06:57:24 CDT 2007


Lisandro Dalcin wrote:
> BTW, Could you please teach me some easy way of replacing in PETSc
> source code the following:
>
> 'something>comm'    by   '((PetscObject)something)->comm'
>
> I never found the time to learn regular expresions and 'sed'  :-(.
>
>   
Try something like the following:

sed -e 's/\(\w*\)\(\s*->\s*comm\)/((PetscObject)\1)\2/g'

here \w*  should match any number of alfanumerics + underscores
        \s*    matches any number of blanks

in the second part of s/part1/part2/,
the \1 substitutes the bit in part1 between the first pair of \( .. \)
and \2 substitutes the second pair.

Always be careful using this type of automated replacements as 
unexpected behaviour is always to be expected! You might want to xxdiff 
the results for instance.

Cheers
Stephan




More information about the petsc-dev mailing list