This is my code:
#!/bin/bash -e
dirs=( * )
for f in "${dirs[@]}"
do
while IFS= read -r line; do
case "$line" in
*disabled\>true* )
sed -i '1i "$f"' list.txt;;
esac
done < "$f/config.xml"
done
Instead of sed, I tried echo and printf too but the the file list.txt is always empty. Why am I not able to append to file?
echo "$f" >> list.txt;;
printf '%s\n' "$f" >> list.txt;;
sample config.xml file under test folder:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<disabled>true</disabled>
</project>
Goal: Print "test" into list.txt, if test/config.xml has <disabled>true in it.