Sample Header Ad - 728x90

find & sed (search and replace)

65 votes
1 answer
148088 views
I'm using the following command on my mac: $find . -name “*.java” -exec sed -i ’s/foo/bar/g’ {} \; and it seems to have no effect. I have two files in the directory that end in .java, which both have the foo text in them. Am I missing something? **EDIT : Results from request of comments** [aafghani-03:~/test amirafghani]$ find . -name "*.java" -exec sed -i 's/foo/bar/g' {} \; sed: 1: "./bar.java": invalid command code . sed: 1: "./foo.java": invalid command code .
Asked by Amir Afghani (7373 rep)
Apr 18, 2012, 06:59 PM
Last activity: Jun 28, 2025, 10:35 AM