I have files that contain a string OLD. I want to replace this string with NEW. I want to do that not just in current directory but in all sub directories, so recursively.
The thing is, I am on Solaris (v11.3) and the following commands:
sed
and
perl
always return me : illegal option.
f.e. I tried : sed -i -e 's/OLD/NEW/g' * and i got : " - i illegal option "
Is there any alternative ? I would also be ok with a bash script. This is a productional environment and I cannot install any editor unfortunately.
UPDATE : this works as I want it to:
perl -pi -e 's/OLD/NEW/g' *
But it works only for files in current directory. For all subdirectories it returns me:
Can't do inplace edit: Folder_upgrades is not a regular file. ... ...
But if I move to Folder_upgrades and execute the command, it works.
What should I add to do it recursively, so I run it only once and it will do the work in all files in all sub directories ?
SOLUTION UPDATE: this one works exactly as I wanted, recursively. Although it returns an error about files not being regular, it still does the job.
find . -exec perl -pi -e 's/OLD/NEW/g' '{}' \;