With out anything to test it, I can only make some assumptions.
I see what you are trying to do with outputname, but try this:
Code:
for x in *.kml
do
outputname=`echo $x | sed 's|.kml|.csv|g'`
cat $x | grep "<coordinate" | sed 's|<coordinates>||g' |
sed 's|,0</coordinates>||g' sed 's|\t||g' >> "$outputname"
done
anything wrapped in `` will execute the command, and then use its value. VAR=`echo hi` is the same as VAR="hi"
You don't need to put the last $outputname in those quotes because its not a command anymore. We already executed it at the top. This will execute the command each time it loops.
I assume you want to dump all your changes into a .csv file instead of a .kml file, so in the echo command you should use $x instead of $file1 ($1) which is only one file (or maybe many with *.something, but that would be redundant), not each of the .kml files you are using.
Also, I assume you are going to want to cat each file and in the loop and save it as a .csv, you will need to use the $x instead of $1 to do that.
You can use anything in place of $x, it's just standard practice for me. $file would work too, but i don't like using it because its a command (not that it will hurt anything).
You may need "" around $x if you have problems. You can also use them around the entire echo command like this: "`echo $x | sed 's|.kml|.csv|g'`" command
Last note, you can use anything in sed for a divider, as long as its the same. Not using / helps to not have to use a \ every time you have something you need to cancel.
Code:
sed 's/\/usr\/local/\bin/\/usr\/bin/g'
can also be
Code:
sed 's|/usr/local/bin|/usr/bin|g'
or
Code:
sed 's#/usr/local/bin#/usr/bin#g'