search & replace on multiple files

Dan Nelson dnelson at allantgroup.com
Wed Jul 23 13:07:43 PDT 2003


In the last episode (Jul 23), Scott I. Remick said:
> Hello... I'm trying to figure out a way to pull off the following:
> 
> I have a subdir with many different sorts of text files (some nested in
> additional subdirs, so recursion would be necessary) that need to have a
> search & replace done on them. What's a quick way to script a global search
> & replace on many/all text files in nested subirs? 

find . -type f | xargs sed -i.bak "s/oldtext/newtext/g"

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list