14 lines
		
	
	
		
			276 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			276 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
#
 | 
						|
# Find and replace by a given list of files.
 | 
						|
#
 | 
						|
# replace foo bar **/*.rb
 | 
						|
 | 
						|
find_this="$1"; shift
 | 
						|
replace_with="$1"; shift
 | 
						|
 | 
						|
items=( $(ag -l --nocolor "$find_this" "$@") )
 | 
						|
for item in ${items[@]}; do
 | 
						|
  sed -i "s/${find_this}/${replace_with}/g" "$item"
 | 
						|
done
 |