0

Many of my sites consists of hundreds of HTML files, and I often have to make changes via "Find and replace" in all files simultaneously. I use a combination of FTP, cPanel's file manager, Notepad++ and Microsoft Expression Web for this purpose and would like to know if there is a more efficient way to do this.

I use Notepad++ for most simple "find and replace" searches and for regular expression searches. However, Notepad++ does not allow you to paste multiple lines of text, so I am forced to use Expression Web to replace larger blocks of code, especially if it has lots of white spaces and line breaks. Expression Web is not the fastest thing in the world, unfortunately, and a combination of that and having to switch between programs slows down my workflow quite a bit.

I know that people use grep via putty, but again, that would only work with simple replacements, not large, multiline blocks that you just need to copy and paste. I would like to know two things:

1) What's a good replacement for Expression Web to do "find and replace" of large blocks of text or code in Windows?

2) Is there a way to run this process with files still being on the server? If not, is it possible to at least reduce the number of steps? Right now it's taking way too many steps:

  1. Creating a backup of the site in cPanel
  2. Downloading and extracting the backup
  3. Editing the files
  4. Zipping the edited files into a single archive
  5. Uploading the archive via FTP
  6. Going back to cPanel to delete old files and to extract the new archive.
1
  • Do it over ssh: prepare the sed/awk/perlcommand and then send it to each server over ssh. You can even script the whole thing so it automatically goes through all your servers or use ansible with a configuration file that lists all your servers. You could perform the backup right before the substitution: ssh <server> 'tar...; sed...'.
    – simlev
    Jul 19 '17 at 22:03
0

You can search and replace multiline text in Notepad++ using \n as lines delimiter

And you can use sed to search and replace multiline text: https://unix.stackexchange.com/questions/26284/how-can-i-use-sed-to-replace-a-multi-line-string

1
  • Typing multiple delimiters out manually for entire paragraphs of formatted text? Instead of copying and pasting? It would take me probably until the next century to finish all my projects if I did it that way.
    – Knocks X
    Jul 25 '15 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.