#!/bin/sh PHPBIN="php -d error_reporting=0 "; if [ -f "$1" ]; then CSV=$(echo $1 | sed s/".txt"/".csv"/g); echo -n > $CSV; while read f; do ADDRESS=$(echo $f) export ADDRESS; $PHPBIN << 'EOF' >> $CSV; $v) { switch ("$k") { case "lat": echo "$v, "; break; case "lon": echo "$v"; break; } } } ?> EOF echo >> $CSV; done < $1 # Remove newline character at the end of a file truncate -s -1 $CSV else echo "Usage: $0 "; fi