Solved

Many Files - Change

Posted on 1997-05-02
3
181 Views
Last Modified: 2010-04-21
I am using C-shell .

I would like to change the contents of many files at once
i.e. change say the occurrence of 'xyz' in many files to
'abc' .
All the files are in one directory .

I guess I need to create an executable file - I've tried one
starting with '# /bin/csh -f' and this works OK .

Thanks - Brian Roberts
0
Comment
Question by:BlueFin
3 Comments
 

Accepted Solution

by:
fsgreen earned 100 total points
ID: 2006259
here's a script that will do it:

#!/bin/csh
foreach i (*)
sed s/"xyz"/"abc"/ < $i > tempfile
mv tempfile $i
end

      doug.
0
 

Author Comment

by:BlueFin
ID: 2006260
This is the first time I've used experts-exchange and the
answer I have received solves my problem .
I am very pleased with this .
I am not sure about your grading system re
excellent and good - as I don't know how easy my
question was to answer for an expert .
0
 

Expert Comment

by:smagt
ID: 2006261
There also exists a program called "fgres" - fast grep and substitute, available from several ftp servers.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question