A photo of Mitesh Shah

Mitesh Shah

Linux Enthusiast
System Administrator

Email Skype Github Twitter Google+ Resume Hire Me Keybase LinkedIn Stackoverflow


  • Sometimes we need functionality which can perform search and replace for us so we can directly copy paste codes.

For Example:

[mitesh@shah ~]$ cat /etc/nginx/sites-available/example.com
server {
  server_name example.com www.example.com;

  access_log /var/log/nginx/example.com.access.log rt_cache;
  error_log /var/log/nginx/example.com.error.log;

  root /var/www/example.com/htdocs;
  index  index.html index.htm;

  location / {
    try_files $uri $uri/ /index.html;
  }

  include common/locations.conf;
  include /var/www/example.com/conf/nginx/*.conf;

}
  • Instead of copy above codes and manually search and replace on vim we can directly perform search and replace on this page only.

Perform Search & Replace

  • Right click on this page
  • Click on Inspect Element
  • Click on Console
  • Copy Paste Following Code and Press Enter.
jQuery('body').html(function(index,html){
return html.replace(/example.com/g,'mitesh.com');
});

Perform Search and Replace on Webpages

  • Once you press Enter check above code
  • You can see example.com is replaced by mitesh.com just like below image.

Perform Search and Replace on Webpages





Post Navigation