If you were looking for as replacing text within multiple files into a single line of command, have reached the right place. Many times we have to find or make changes to a text given to start and we do not know, nor in any file, document or directory can be.

Let's say you change IP address to the server, and it is necessary to make changes in all configuration files and logs which show the IP earlier.

To not be looking for hours among all the files on our server, move them to replace these tips on linux Alphanumeric strings.

  • To replace a text string or wherever they appear in the files:
  •   deathbian: ~ # find / path / directory "*. txt" | xargs perl-pi-e 's / text / replacement / g' 
    


  • To replace the first time you see the text:
  •   deathbian: ~ # find / path / directory "*. txt" | xargs perl-pi-e 's / text / replacement /' 
    


  • To replace all the files into a directory:
  •   deathbian: ~ # for arg in `` ls-C1; do perl-pi-e 's / text / replacement / g'; done; 
    


There are a lot of combinations possible using the shell command line. Take the first search:

  deathbian: ~ # for arg in `find / your / home / dir-name" *. txt "`; do perl-pi-e 
  's / text / replacement / g' $ arg; done; 


Popularity: 45% [?]