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:
#!/bin/bash
for f in `find /myDir/ -iname "*.xml"`
do
awk '/<string name="my\/ attribute" optional="false">/,/<\/string>/ {sub(/<value>(.*)<\/value>/,"<value>none</value>")}1' $f >$f
done
You must use a temporary file: