M
M
Merca7092017-06-05 18:01:28
linux
Merca709, 2017-06-05 18:01:28

How to autocorrect a line in a large number of .php files on Linux?

Please tell me the syntax of the Linux command so that you can do auto-replacement of the line (search and replace) in a large number of php-files located in one folder (about a million files). There are many options, but the fastest one is needed.
Tried:

time find ./ -type f -exec sed -i 's/TEXT-1/TEXT-2/g' {} \;
- works, but works slowly (I went through a million files for a week and did not finish it)
They suggested another command:
find -type f -name '*.php' -print0 | xargs -0 -P 8 sed -i -- 's/TEXT-1/TEXT-2/g'
- which should cope quickly, but does not work, after a while it gives errors:
sed: -e expression #1, char 1: unknown command: `�'

Please tell me the correct command syntax to cope with the task. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Merca709, 2017-06-07
@merca709

figured it out
In the end - a working solution, can someone come in handy

D
devalone, 2017-06-05
@devalone

Choose any: https://unix.stackexchange.com/questions/112023/ho...

Y
younghacker, 2017-06-05
@younghacker

What happens if you add -z to sed ?

`-z'
`--null-data'
`--zero-terminated'
     Treat the input as a set of lines, each terminated by a zero byte
     (the ASCII `NUL' character) instead of a newline.  This option can
     be used with commands like `sort -z' and `find -print0' to process
     arbitrary file names.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question