Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux command to find files and replace with another file

I'm looking for a linux command to search a folder directory and it's subfolders for a file by name and replace all of them with a copy of another file. Any idea?

like image 351
samira Avatar asked Feb 10 '16 02:02

samira


1 Answers

Assuming you have the replacement file in your home directory (~), you can use find to do the replacing. This will find all boom.txt files and replace them with the replace.txt file (keeping the boom.txt name).

find . -name "boom.txt" -exec cp ~/replace.txt {} \;
like image 87
user1683793 Avatar answered Sep 21 '22 12:09

user1683793