Sed script maybe?

I have a lot of script files that were created by Extract in a dir that no longer exists. Now that I have to run these scripts they 'all' have to be changed. I'm looking for a way to do a 'mass' change if possible.

So far, I've dumped all of the script file names to a file and sorted them to eliminate duplicates. Is there some way to have a script read that file as input to the sed command?

Any/all help is appreciated greatly.

:confused:

ive used this when changing between my test and production system

replace all files in current directory having h14 with ess01
the new files will be written to the tmp directory

create mask file with syntax s/string to replace/new string/g

mask example: s/h14/ess01/g

at command line:
$> for i in `ls`
Shell > do
Shell > sed -f mask $i > ../../tmp/$i
Shell > done

hth

or see this thread: http://www.unix.com/showthread.php?threadid=4056

Actually the line with the "for" statement should read like this.

$> for i in `cat filename`

Because HOlli has placed the names of the files in file. If HOlli was just doing every file in a directory, the first example would work fine.

Hopefully HOlli has put them in one column left justified.

The only other thing that might be questionable is that the script puts a new copy of the file in /tmp instead of replacing the original which is okay if you want to keep the old scripts.

Actually the referenced link is MY handywork. Thanks for noticing!!

Kelam.

:smiley:

good point Kelam,

its also good to know that if you use a mask file for your sed command you can perform multiple replaces by separating the sed entries by a semicolin.

ex: s/h14/ess01/g;s/test_scripts/scripts/g

will replace all 'h14' with 'ess01' and all 'test_scripts' with 'scripts'

Thank you for the suggestions! I'm new at this and the guidance is very helpful. I think I can do it now!

Thanks again!