Is there a way to set everything before the comma as say var1 and everything after the comma as var2. Then be able to process those vars, then move onto the next set until theres no more sets?
All that data was extracted from a KML using:
sed -n 's/.*<coordinates>\(.*\)\,.*/\1/ip;T' Test.kml
Maybe do the same thing only extracting them individually from the KML instead of the other file and then processing them, then moving to the next and so forth?
a is -94.49109387652327 b is 39.2956736296775
a is -93.0906917141962 b is 38.72762798197614
a is -90.57659976220785 b is -40.25685140137304
a is -92.340961875134 b is 39.44522321129584
a is 92.340961875134 b is 39.44522321129584
a is -94.72083812873272 b is 37.63567097374739
This is just to compile some stuff for my reference.
sed -n 's/.*<coordinates>\(.*\)\,.*/\1/ip;T' Test.kml
-94.49109387652327,39.2956736296775
-93.0906917141962,38.72762798197614
-90.57659976220785,40.25685140137304
-92.340961875134,39.44522321129584
-92.340961875134,39.44522321129584
-94.72083812873272,37.63567097374739
sed -n 's/.*<longitude>\(.*\)<\/longitude>.*/\1/ip;T' Test.kml
-94.49109387652327
-93.0906917141962
-90.57659976220786
-92.340961875134
-92.340961875134
-94.72083812873272
#Math with decimals
a=`echo "1+1.2" | bc` && echo $a
2.2
a=`dc -e '1.2 1+p'`
echo $a
2.2
#Extracting coords as vars then processing
sed -n 's/.*<coordinates>\(.*\)\,.*/\1/ip;T' Test.kml | while IFS=, read A B; do
echo a is $A b is $B
echo "asdf"
done
a is -94.49109387652327 b is 39.2956736296775
a is -93.0906917141962 b is 38.72762798197614
a is -90.57659976220785 b is 40.25685140137304
#Multi Condition if statement
if [ $i = "+" -o $i = "-" -o $i = "/" -o $i = "%" ]; then
$x=$vr1
else
print "You have entered an invalid option."
Hah yea it just made sense. Easiest way to transport code from home to work. I tried out
sed -n 's/.*<coordinates>\(.*\)\,.*/\1/ip;T' Test.kml | while IFS=, read A B; do
echo a is $A b is $B
echo "asdf"
done
at home on Ubuntu 9.04 and it worked but now it says that the command is garbled on solaris 10. I had a feeling this would happen as Im sure my Solaris box must be running an older version of pretty much everything. Can anyone think of a more flexible or older sed/bash friendly way perhaps?
a is 39.2956736296775 b is
a is 38.72762798197614 b is
a is 40.25685140137304 b is
a is 39.44522321129584 b is
a is 39.44522321129584 b is
a is 37.63567097374739 b is
Oh and I got the raw coords for a.txt from the Test.kml using
sed -n 's/.*<coordinates>\(.*\)\,.*/\1/ip;T' Test.kml
But the sed command does work fine on the a.txt at home hopefully its true for work too!