hi Gurus,
I'm a newbie in scripting please check my script if this is correct. I think there's something wrong with it but I;m not sure. I'm trying to create multiple lines using awk from external xml files but i want to add additonal info in the data manually
Since i don't knwo how to create scripts to read xml files, i will need to cut the data beforehand and save it as text files
text_files contains:
<data DAY= "MONDAY" FOOD_TYPE = "FRUITS" FRUIT_TYPE= "FRUIT_{fruit}" /data>
<data DAY="TUESDAY" FOOD_TYPE= "HEALTHY" FRUIT_TYPE= "HEALTHY_{fruit}" /data>
so I need to replaced fruit with
apple, banana, orange, pear, strwaberry and the amount of yoghurt need to be incremented by 1 starting with 23
so the output files will be
I love eating 'FRUIT_apple' with 23g of youghurt
I love eating 'FRUIT_banana' with 24g of yoghourt
and so on
#!/bin/bash
fruit = (apple, banana, orange, pear, strawberry)
i = 23
for index in 0 1 2 3 4
do
awk -v q="'" 'BEGIN {FS = ""}; {print "I love eating" q$3q"_"${[fruit]} "with" $i "g of yoghourt"} ' data.txt
i++
done
> output.txt
echo "subtituion has been made succesfully...."
exit 0
Thanks in advance