[LUNI] Global search and replace

d.w. harks dave at psys.org
Mon Dec 18 20:16:54 CST 2006


With carefully-arranged electrons, Benjamin Mayer Stocks wrote:
> Hi All,
> Can someone lend me a quick hand: I need to make a global change in a
> bunch of .h files, the trick is that this is a ClearCase file system so I
> can't run SED on every .h file or SED will change the time stamp and
> ClearCase will call it a hijacked file.
> 
> So can someone help me write a bash shell command to find all .h files
> under the current directory, grep the file and if the string is present
> only then run the SED command?
> 
> Thanks!
> 
> Ben

Assuming you're in the top-level directory for the project within your
VOB...

for each in `grep -lR <pattern> .`; do 
cleartool checkout $each;
<sed command> $each;
cleartool checkin $each;
done

Alternatively, you could just hijack all the files and then run through
all the hijacked files and check them out, use the hijacked version as
the new version, and then check back in...

d
-- 
David W. Harks <dave at psys.org>


More information about the luni mailing list