Answer the question
In order to leave comments, you need to log in
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) 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: `�'
Answer the question
In order to leave comments, you need to log in
figured it out
In the end - a working solution, can someone come in handy
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 questionAsk a Question
731 491 924 answers to any question