loop over directory and file bash script - awk does not write to file

I would like to traverse through some directories that contain xml files. To each file I would like to apply an awk command and write the output to the file again. The file that is written is empty, though. Why? I use the following script:

for f in `find /myDir/ -iname "*.xml"`
   awk '/<string name="my\/ attribute" optional="false">/,/<\/string>/ {sub(/<value>(.*)<\/value>/,"<value>none</value>")}1' $f >$f


You must use a temporary file:

awk ... "$f" > "$f".tmp; mv "$f".tmp "$f"

Need Your Help

Symfony2 Swiftmailer sends emails when the project is in my PC's virtual server but doesn't when I upload it to shared hosting

symfony2 swiftmailer

When my Symfony project is in my PC's wamp it sends emails just fine but after I upload it to shared hosting it doesn't but after some time it still redirects and I get "Success" flashbag. The only

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.