Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I do this as I may have hundreds of files that are not writable but need the update?
I'll be using this find command to search the files:
find . -type f -name "*" -exec grep -ls ABC {} \;
Then I'll be using sed or perl to change "ABC" to "XYZ" for example.
Some of the files will be writable and some won't. Thanks for any assistance you can give.