[ Home ]      [ Blog ]      [ Tutorials ]      [ Aviation ]      [ Manuals ]      [ Grad School ]
 

Sunday, May 14, 2006

Linux search and replace in multiple files

So, I needed a little tool to perform search and replace on multiple files in a Linux environment. Here's how I did it:


#!/bin/sh
for file in *; do
mv $file $file.old
sed 's/FINDSTRING/REPLACESTRING/g' $file.old > $file
rm -f $file.old
done
   ©Copyright 2004. All Rights Reserved