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

IBM XL C/C++ Compiler: check compiler mode using preprocessor directive

c++ compiler-construction xlc

I am trying to compile a sample c++ file test.cpp using IBM xlC compiler on AIX system. The file should be compiled in both 32-bit and 64-bit modes. I am using following commands to compile them in...