Posts

Showing posts with the label shell

One liner shell command to find and rename to lowercase all SHP, DBF, and SHX file extensions

One liner shell command to find and rename to lowercase all SHP, DBF, and SHX file extensions starting from current directory: EXTENSIONS="SHP SHX DBF" for E in $EXTENSIONS ; do export E; export e=`echo $E | tr '[:upper:]' '[:lower:]'`; for f in `find . -name "*.$E"` ; do mv $f `echo $f | sed "s/$E/$e/"`; done ; done Useful when you get your shapefiles over from Windows and mapserver won't cooperate.

Using SQLite to keep state in shell scripts

Bash shell scripting is one the things that I miss more on the times I work on Windows. Even as good as shell scripting is, sometimes I wish it was easy to keep track of state across script executions, for instance when a script executes a rsync at short intervals. In that case I don't care if one particula rsync fails, but I definitely care if it fails, say, ten times in a row or for more than a day. To do this I need some kind of way to keep state and record each run exit status. The simplest approach that I could think of is to use SQLite . Copied straight from the SQLite site:  SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain. As I said, in this example I'll show how to track the status of a series of rsync operations, all run from a central node and pushed to remote nodes...