How to find all files with same name in different directories and update specific text in each file in...

What does 丫 mean? 丫是什么意思?

What helicopter has the most rotor blades?

Does the main washing effect of soap come from foam?

How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?

How does the body cool itself in a stillsuit?

How do Java 8 default methods hеlp with lambdas?

Statistical analysis applied to methods coming out of Machine Learning

How to resize main filesystem

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

How to achieve cat-like agility?

Meaning of 境 in その日を境に

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

Proving that any solution to the differential equation of an oscillator can be written as a sum of sinusoids.

Did any compiler fully use 80-bit floating point?

Marquee sign letters

Vertical ranges of Column Plots in 12

Is there a verb for listening stealthily?

Did John Wesley plagiarize Matthew Henry...?

Why not use the yoke to control yaw, as well as pitch and roll?

How to make triangles with rounded sides and corners? (squircle with 3 sides)

Random body shuffle every night—can we still function?

What is "Lambda" in Heston's original paper on stochastic volatility models?

An isoperimetric-type inequality inside a cube

Noise in Eigenvalues plot



How to find all files with same name in different directories and update specific text in each file in Linux_Bash?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do I use find to copy all found files to a new name in their same directories?Find and replace text in multiple filesHow to replace one line to two lines or more on a text file using the “find and replace mode”?How can I find and replace multiple blocks of text in multiple documents all at once?How do I recursively go through directories and name a file after the directory?regarding swp files and same file opened in different vncHow can I restrict a bash find to only specific sub-sub-directoriesRecursively find all subfolders' files and symlink them with their containing folder's nameHow to create a file for each line of text with File name as Field1, Field 2?Find all files & directories with group different than owner





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I've a bunch of files with same name "abc.php" in different directories. I want to find all files and replace the specific line of text i.e, "hello" to "bye" in each file. I've the text multi times repeat in each file that i've to update. Is there any way to do this??










share|improve this question





























    0















    I've a bunch of files with same name "abc.php" in different directories. I want to find all files and replace the specific line of text i.e, "hello" to "bye" in each file. I've the text multi times repeat in each file that i've to update. Is there any way to do this??










    share|improve this question

























      0












      0








      0








      I've a bunch of files with same name "abc.php" in different directories. I want to find all files and replace the specific line of text i.e, "hello" to "bye" in each file. I've the text multi times repeat in each file that i've to update. Is there any way to do this??










      share|improve this question














      I've a bunch of files with same name "abc.php" in different directories. I want to find all files and replace the specific line of text i.e, "hello" to "bye" in each file. I've the text multi times repeat in each file that i've to update. Is there any way to do this??







      linux bash find-and-replace






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      user1002358user1002358

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          1














          This finds all *.php files in your current directory . recursively and replaces "hello" with "bye" multiple times in each line it finds.



          find . -name "*.php" -print0 | xargs -0 sed -i 's/hello/bye/g'


          Make sure you make a backup of your current directory before you apply this.



          Or alternative:



          find . -name "*.php" -print0 | xargs -0 -I{} sh -c "sed 's/hello/bye/g' '{}' > '{}'.new"


          This will not overwrite each file, but create a new file with the replacements, e.g. "abc.php" -> "abc.php.new".






          share|improve this answer
























          • Thanks Freddy It's Working as i want.

            – user1002358
            2 hours ago












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1428102%2fhow-to-find-all-files-with-same-name-in-different-directories-and-update-specifi%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This finds all *.php files in your current directory . recursively and replaces "hello" with "bye" multiple times in each line it finds.



          find . -name "*.php" -print0 | xargs -0 sed -i 's/hello/bye/g'


          Make sure you make a backup of your current directory before you apply this.



          Or alternative:



          find . -name "*.php" -print0 | xargs -0 -I{} sh -c "sed 's/hello/bye/g' '{}' > '{}'.new"


          This will not overwrite each file, but create a new file with the replacements, e.g. "abc.php" -> "abc.php.new".






          share|improve this answer
























          • Thanks Freddy It's Working as i want.

            – user1002358
            2 hours ago
















          1














          This finds all *.php files in your current directory . recursively and replaces "hello" with "bye" multiple times in each line it finds.



          find . -name "*.php" -print0 | xargs -0 sed -i 's/hello/bye/g'


          Make sure you make a backup of your current directory before you apply this.



          Or alternative:



          find . -name "*.php" -print0 | xargs -0 -I{} sh -c "sed 's/hello/bye/g' '{}' > '{}'.new"


          This will not overwrite each file, but create a new file with the replacements, e.g. "abc.php" -> "abc.php.new".






          share|improve this answer
























          • Thanks Freddy It's Working as i want.

            – user1002358
            2 hours ago














          1












          1








          1







          This finds all *.php files in your current directory . recursively and replaces "hello" with "bye" multiple times in each line it finds.



          find . -name "*.php" -print0 | xargs -0 sed -i 's/hello/bye/g'


          Make sure you make a backup of your current directory before you apply this.



          Or alternative:



          find . -name "*.php" -print0 | xargs -0 -I{} sh -c "sed 's/hello/bye/g' '{}' > '{}'.new"


          This will not overwrite each file, but create a new file with the replacements, e.g. "abc.php" -> "abc.php.new".






          share|improve this answer













          This finds all *.php files in your current directory . recursively and replaces "hello" with "bye" multiple times in each line it finds.



          find . -name "*.php" -print0 | xargs -0 sed -i 's/hello/bye/g'


          Make sure you make a backup of your current directory before you apply this.



          Or alternative:



          find . -name "*.php" -print0 | xargs -0 -I{} sh -c "sed 's/hello/bye/g' '{}' > '{}'.new"


          This will not overwrite each file, but create a new file with the replacements, e.g. "abc.php" -> "abc.php.new".







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          FreddyFreddy

          2735




          2735













          • Thanks Freddy It's Working as i want.

            – user1002358
            2 hours ago



















          • Thanks Freddy It's Working as i want.

            – user1002358
            2 hours ago

















          Thanks Freddy It's Working as i want.

          – user1002358
          2 hours ago





          Thanks Freddy It's Working as i want.

          – user1002358
          2 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1428102%2fhow-to-find-all-files-with-same-name-in-different-directories-and-update-specifi%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...