Skip to main content
Version safe for filenames with spaces
Source Link
Furgas
  • 2.9k
  • 1
  • 20
  • 29

The simplest way for me is

grep -rlrlZ oldtext . | xargs -0 sed -i 's/oldtext/newtext/g' 

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

The simplest way for me is

grep -rlZ oldtext . | xargs -0 sed -i 's/oldtext/newtext/g' 
Rollback to Revision 1
Source Link
Anatoly
  • 5.8k
  • 1
  • 17
  • 8

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

If your text includes the / path character you can substitute with another delimiter character like so:

grep -rl 'oldtext/' . | xargs sed -i 's|oldtext/|newtext/|g' 

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

If your text includes the / path character you can substitute with another delimiter character like so:

grep -rl 'oldtext/' . | xargs sed -i 's|oldtext/|newtext/|g' 

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 
added 177 characters in body
Source Link
Daniel Sokolowski
  • 12.5k
  • 4
  • 75
  • 58

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

If your text includes the / path character you can substitute with another delimiter character like so:

grep -rl 'oldtext/' . | xargs sed -i 's|oldtext/|newtext/|g' 

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

The simplest way for me is

grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g' 

If your text includes the / path character you can substitute with another delimiter character like so:

grep -rl 'oldtext/' . | xargs sed -i 's|oldtext/|newtext/|g' 
Source Link
Anatoly
  • 5.8k
  • 1
  • 17
  • 8
Loading