I'd like to be able to fetch OS X's current estimate of location from the the command-line so that I can script based on it. Is there a tool that does this?

I've found apps like locations that let you trigger actions based on location but I haven't found anything that let's you fetch the actual location data.


I was looking for this, too, and failed to find one... So, I wrote one!

It's pretty simple at the moment, but it seems to basically work. I called it get-location, and you can get it from github (follow the link, above).

For the moment, I just print out the second location I receive from the service (I skip the first one, since it can be cached and old – in a future version, perhaps this will be configurable, or it's an easy hack (change the hits check to be > 0, instead of > 1) in the code, if you don't want to wait for that (I may or may not change it soon).

Anyway, it then prints out the results, like so (note: location data here has been changed to something made up):

$ ./get-location
Final location: <+12.34567890, +12.34567890> +/- 176.00m (speed 0.00 mps / course -1.00) @ 2012-04-10 13:57:53 +0200

Another TODO item is to add other formats, and/or let you specify your own. I may add this soon, or I may add it later. Or: Send me a pull request. :) (Feature requests and bug reports also welcome, preferably via the github system. Also, check the README on github to see what I've already thought of.)

I hope you (and others) find this helpful.

EDIT: Now with command-line options and a few different output formats.


Well, I haven't gotten it to work... But http://code.google.com/p/corelocationcli/ might solve your issue....

This also seems to be a more stable package? http://iharder.sourceforge.net/current/macosx/locateme/

(The issue I am having with both, might be because I am trying these on Mountain Lion.... )

While not built-ins, they both appear to use CoreLocation services....

  • Both solutions seem to be broken on Mountain Lion. Did you manage to get it working somehow, or found something else working on OS X 10.8? I’m sure I am not the only one interested in this ... thanks! – myhd Dec 18 '12 at 21:32
  • I really haven't messed with it at this time. While being neat, I was really looking for a Find My iPhone type of code for portables. – Benjamin Schollnick Feb 25 '13 at 16:08
  • 1
    Thank you, I'm the author of CoreLocationCLI and just noting that it is moved to github.com/fulldecent/corelocationcli and has minor improvements since then – William Entriken Aug 27 '14 at 0:57
  • LocateMe works for me on OS X El Capitan (10.11.6). Thanks for the link! – Noah Sussman May 24 '17 at 3:22

here you go

lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|sed -nr s/'^.*My IP address city: (.+)$/\1/p'

require lynx


  • 1
    Nota bene: This is not the same thing. Potentially useful, but not the same thing. In particular, this requires having full internet access, whereas CoreServices I believe can run without that, as long as wifi is enabled. And anyway, even if I'm wrong about that, it uses WIFI-based location finding (and anything else CoreLocation might use, now or in the future), rather than just IP address, which is potentially much more accurate. (See, e.g., here.) – lindes Apr 10 '12 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.