source: dynamico_lmdz/simple_physics/bash/replace_print.sh @ 4244

Last change on this file since 4244 was 4195, checked in by dubos, 5 years ago

simple_physics : scripts to facilitate transition to logging feature

  • Property svn:executable set to *
File size: 695 bytes
Line 
1#!/bin/bash
2
3echo <<EOF
4usage : replace_print file1 file2 ...
5This script replaces occurences of PRINT and WRITE with the macro WRITELOG
6User is asked for confirmation before overwriting original file.
7This script is basic and you should check results as corner cases are not handled.
8EOF
9
10function replace()
11{
12    FILE=$1.new
13    cp -f $1 $FILE
14# WRITE => WRITELOG
15    sed -i -e "s/\bwrite(\b/WRITELOG(/g" $FILE
16    sed -i -e "s/\bWRITE(\b/WRITELOG(/g" $FILE
17# print * => WRITELOG(*,*)
18    sed -i -e "s/\bprint\*\,/WRITELOG(*,*) /g" $FILE
19    sed -i -e "s/\bPRINT\*\,/WRITELOG(*,*) /g" $FILE
20    diff $1 $FILE
21    cp -i -u $FILE $1
22    rm -f $FILE
23}
24
25for FILE in $* ; do
26    replace $FILE
27done
Note: See TracBrowser for help on using the repository browser.