[H-GEN] Useful not so obvious tips

Andrae Muys andrae at tucanatech.com
Mon Oct 25 21:48:29 EDT 2004


Anthony Irwin wrote:
> [ Humbug *General* list - semi-serious discussions about Humbug and     ]
> [ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
> 
> Hi,
> 
>  From the combinations of the find that were mentioned I did the following.
> 

A couple simple command lines I particularly like

$ find ./src -name '*.java' -exec grep -Hn Foo {} \;

- print the file name, line number, and line from any file with 
extension .java in the subdir src which contains the string Foo.

$ find ./src -name '*.java' -exec sed -e "s/Foo/Bar/g" -i.bak {} \;

- replace all occurances of Foo with Bar in any file with extension 
.java in the subdir src; make a backup of the original file with 
extension .bak if changes are made.

Andrae

-- 
Andrae Muys                do { ... }
andrae at tucanatech.com      while (low != (high - 1));
Senior Engineer            assert low == (high - 1);
TucanaTech                     -- Can you be more defensive?





More information about the General mailing list