Posts for Tag: command line

OSX - Command line battery cycles information

Here's how to get the number of battery charging cycles on your laptop on OSX:

    ioreg -l | grep LegacyBatteryInfo | cut -d '{' -f 2 | tr -d \} | tr ',' '=' | awk -F'=' '{print $12}'

'Internet speed test from the command line'

Here's a neat trick: Measuring your Internet download speed from the command line.

Basically you need wget to download a big file (download to /dev/null will not waste disk space ;)) and simply check the average speed at the end.

Something like:

wget -O /dev/null http://speedtest.ams01.softlayer.com/downloads/test10.zip

Will give you:

Resolving speedtest.ams01.softlayer.com... 159.253.132.18 Connecting to speedtest.ams01.softlayer.com|159.253.132.18|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 11536384 (11M) [application/zip] Saving to: ‘/dev/null’ 100%[====================================================================================================================================================================================================================================>] 11,536,384 897KB/s in 13s 2013-09-05 17:36:36 (901 KB/s) - ‘/dev/null’ saved [11536384/11536384]

In this case, my download speed was 901KB/s.

But it gets better: Since you might not be near the server i am using to test, you can pick a closer one. Just replace the "ams01" part of the url with one of the [servers on this page](http://speedtest.ams01.softlayer.com/speedtest/). For simplicity, i've compiled a list:

- Amsterdam, The Netherlands: **ams01** (the one used in my test) - Singapore, Singapore: **sng01** - Seattle, USA: **sea01** - San Francisco, USA: **sjc01** - Dalas, USA: **dal01** - Dalas, USA: **dal05** - Dalas, USA: **dal07** - Houson, USA: **hou02** - Washington DC, USA: **wdc01**

So for example - if you live near San Francisco - use "http://speedtest.**sjc01**.softlayer.com/downloads/test10.zip" as the url (notice the change in bold).

**Bonus:** Create a shell alias and you can call the speed test anytime using - well - "speedtest". Here's an example for the FiSH shell and bash.

FiSH: Add to your **config.fish** function speedtest; wget -O /dev/null http://speedtest.ams01.softlayer.com/downloads/test10.zip; end

BASH: Add to your **.bash_profile** alias speedtest='wget -O /dev/null http://speedtest.ams01.softlayer.com/downloads/test10.zip'

Happy (fast) Interneting.

Change file modified and creation date/hour

Here's how to change a file's modified date:

touch -mt 201102260000 <file>

Where "201102260000" is year, month, day, hours, minutes all glued together (so 2011-02-26 at 00:00).

Also, if you want to change both the modified and creation date, then:

touch -t 201102260000 <file>

This works on OSX and (i'm assuming, since touch also exists there) Linux/Unix.

Update server not available (error- 12) on OSX

Here's the definitive fix for this annoying-as-hell problem:

1. Run the following on the command line: sudo /Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/Resources/install.py --uninstall 2. Restart Chrome.

Taken from here.

 

How to get the "watch" command line tool on OSX

1. Download it. curl -O http://sveinbjorn.org/files/software/watch-0.3-macosx.zip 2. Unzip and move into folder.

2. Make file executable. chmod +x watch 3. Move it to somewhere in $PATH. sudo mv watch /usr/local/bin/ 4. Done.