So this command will replace abc with XYZ in file.txt in directory tmp
sed -ie ‘s/abc/XYZ/g’ /tmp/file.txt
How do you do a find and replace like this across a large number of files in a directory with a .html extension in one go?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As by your request, here is what it does:
Finds all files that glob to *.html, starting in /start/path
The -exec option tells find, to not just print out the files, but to run a command on them. Inside this command {} is replaced by the file. The -exec option hast to end with a semicolon, which we have to escape with a backslash, else bash will swallow it.
Again, from the OP’s special situation: Put the following into a file called replaceabc.sh
then from the shell prompt