Operating System - HP-UX
1834202 Members
3486 Online
110066 Solutions
New Discussion

Re: Recursive file updates

 
HartfordBala1973
Occasional Advisor

Recursive file updates

Env.: HP-UX B.11.23 - 64 bit

I would like to update a path name in many files in the dir and sub-dir.
For eg. path name like /tech/oracle has to be changed to /appl/oracle in more than 100 files.

Please provide me the syntax.

Thanks & Regards
Balaji
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: Recursive file updates

Hi:

You can craft a simple shell script to 'find()' files and having found a file, use 'sed' to substitute your strings.

We could perform the whole process much more efficiently in Perl, too.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Recursive file updates

I have creatad a script to make changes to an unlimited number of files using simple old_string and new_string syntax (attached). By default, it simply highlights what the old and new lines will look like. It will work on one or more files and will also accept stdin.



Usage: chgafile [ -w ] [ -q ] [ -s ] old-text new-text [ filename(s) ]

-w to write changes (default = preview only)
-q quiet mode (no before/after lines)
-s silent (no output at all except for file or STDOUT) -s also turns on -q for no output at all

old-text and new-text are the strings
one or more files to change or no filenames for STDIN


Bill Hassell, sysadmin