简体   繁体   中英

Search and replace files (Linux)

I'm quite new to Linux. I'm using Linux Mint and I've just found a situation where I have a file which exists multiple times inside the tree/folders of a folder. I want to replace all occurrences of this file with a new version of it. So instead of looking for that file once and again and replacing it with the new one, I wonder if there is any kind of search & replace command for files.

I've already searched for a similar question in stackoverflow, but I was only able to find commands to search & replace TEXT in files, not the file itself.

Can anyone please point me to the right direction?

Thank you.

you can always do it in parts, like:

  1. Get a list of items matching your search.
  2. Replace every match (using mv for example) with your file.

something like:

foreach dir ( `ls | egrep '^(i686\|amd64)\.'` )
   mv yourfile $dir
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM