Changes between Version 1 and Version 2 of Tutorials/ControllingDataOutput

Show
Ignore:
Timestamp:
09/05/08 20:57:31 (5 years ago)
Author:
rpwagner
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials/ControllingDataOutput

    v1 v2  
    4545 
    4646{{{ 
     47#!sh 
    4748#!/bin/tcsh                                                                                                                         
    4849if ( `ls -1 *.hierarchy |wc -l ` != 1 ) exit 
     
    5354    sed -e "s:"$dir1":"$dir2":g" $i > tmp; mv tmp $i        # Replace the directory. sed is rad.                                    
    5455end 
     56}}} 
     57 
     58''If {{{sed}}} scares you, here's a snippet of Python to iterate over a file and replace a string. It does less in 10 lines than {{{sed}}} does in one, but it's easy to drop in other Python scripts. And now I'll go make myself a square wheel... --Rick'' 
     59 
     60{{{ 
     61#!python 
     62fin = open('RD0033.hierarchy') 
     63line = fin.readline() 
     64fout = open('RD0033.hierarchy.new','w') 
     65while line: 
     66    if line.find('/dsgpfs/harkness/NewL7/Dumps/') != -1: 
     67        line = line.replace('/dsgpfs/harkness/NewL7/Dumps/RD0033/','/gpfs/ux455215/L7/RD0033/') 
     68    fout.write(line) 
     69    line = fin.readline() 
     70 
     71fin.close() 
     72fout.close() 
    5573}}} 
    5674