Solved

Many Files - Change

Posted on 1997-05-02
3
183 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

820 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