{"id":643,"date":"2021-11-14T22:25:30","date_gmt":"2021-11-15T03:25:30","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=643"},"modified":"2024-02-08T08:42:54","modified_gmt":"2024-02-08T13:42:54","slug":"search-replace-text-in-a-file-from-command-line","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/search-replace-text-in-a-file-from-command-line\/","title":{"rendered":"Search replace text in a file from command line"},"content":{"rendered":"\n<p>Nginx webroot is defined in the following file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n\n\n\n<p>The following code specifies the webroot in this file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root \/usr\/share\/nginx\/html;<\/code><\/pre>\n\n\n\n<p>I change this webroot using a script. Following script will do this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sed -i -e 's\/\\\/usr\\\/share\\\/nginx\\\/html\/\\\/var\\\/www\/' \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n\n\n\n<p>-e indicates an expression. s\/\/\/ does string search ands replace. We are simply replacing \/usr\/share\/nginx\/html with \/var\/www. \/etc\/nginx\/sites-enabled\/default simply indicate the file we wish to modify.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx webroot is defined in the following file: The following code specifies the webroot in this file I change this webroot using a script. Following script will do this: -e indicates an expression. s\/\/\/ does string search ands replace. We are simply replacing \/usr\/share\/nginx\/html with \/var\/www. \/etc\/nginx\/sites-enabled\/default simply indicate the file we wish to modify.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[512],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-misc"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/643\/revisions\/644"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}