Is this possible?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is this possible?
# 1  
Old 03-11-2004
Question Is this possible?

Hi, I'm a relative newb to Unix, and I'm looking for a bit of help on grep (or sed or something like that)

I want to search a whole bunch of files for the string "$cal" and replace it with the string "$osa". I then want to save all the altered files.

How would I do this?
# 2  
Old 03-11-2004
By the way, all the files are in the same directory or a subdirectory thereof. I'm running Windows 2K, Exceed 6.1.0.0, ksh, and the server runs SunOS 5.8.
# 3  
Old 03-12-2004
This can be done using sed and a loop...
Code:
for file in files*
do
    cp $file $file.bk &&\
    sed 's/\$cal/\$osa/g' $file.bk > $file &&\
    rm $file.bk
done

Or in perl...
Code:
perl -pi -e 's/\$cal/\$osa/g' files*

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question