• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

bash: how to use a > inside a "find -exec"

statik213

Golden Member
I need to do strip a string out of a bunch of html files, so i started reading up on sed and it looks nice.... now sed writes to stdout and I haven't been able to figure out how to get it to write to a file.
so I thought i could do something of this sort:

find ./ -iname '*.html'
-exec sed s/'<script language="JavaScript" src="\/js\/omi\/jsc\/s_code_remote.js"><\/script>'//g '{}' \> '{}'.tmp \;
-exec mv '{}'.tmp '{}' \;

How do I get it to redirect the output in the exec statement? the escapes are killing me....


 
One problem is that sed one-liners are given as the argument to the -e switch. Also, the second part can be quoted more logically. Thus:

-exec sed -e 's/<script language="JavaScript" src="\/js\/omi\/jsc\/s_code_remote.js"><\/script>//g' '{}' \> '{}'.tmp \;

is what I would use.
 
Back
Top