Archive for the 'cygwin' Category

Google Analytics API via cURL

I spend a lot of time in Google Analytics creating custom reports for various things. I usually start with Google Analytics Query Explorer to make sure I’m getting the right data before creating a script to pull in the data for the report. Once I’ve got a good result set, I’ll use cygwin with cURL […]

If a file exists then do (something) in bash

If you need to determine in a file exists in a directory use the first example. Credit to¬† for a simple answer. #!/bin/bash if [ -f path/to/file.txt ] then echo “file exists” fi If you need to know if it does not exist use this: #!/bin/bash if [ ! -f path/to/file.txt ] then echo “file […]

Read lines in a text file with bash

In bash it’s very easy to read a text file line by line and do something to each line. I do this in cygwin a lot to parse logs and other large files. Your input file needs to have unix-style line endings or bash will get very confused. This trips me up a lot when […]