Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X /usr/bin/time verbose flag

I have been trying to run the usr/bin/time command in my terminal (Bash) with the verbose flag --verbose or -v but have repeatedly been getting this error:

/usr/bin/time: illegal option -- v
usage: time [-lp] command.

The command I have been running looks like basically like this:

/usr/bin/time -v python practice.py

Any ideas how to get this to work properly on a Mac? (I have OS X Yosemite)?

like image 785
David A Avatar asked Sep 11 '15 04:09

David A


2 Answers

If you have homebrew, you can get GNU time by installing the gnu-time package:

brew install gnu-time

After that, it’s available as the gtime command:

$ gtime
Usage: gtime [-apvV] [-f format] [-o file] [--append] [--verbose]
       [--portability] [--format=format] [--output=file] [--version]
       [--help] command [arg...]

The case is similar for a lot of other homebrew-packaged GNU utilities for OSX; e.g., you can get the GNU df command with gdf, du with gdu, readlink with greadlink, etc.

The homebrew package that has most of those is coreutils, which installs about a hundred different GNU-flavored commands. Other useful packages: findutils, gnu-sed, gnu-tar.

If you don’t have homebrew installed yet, you can get it with just a single command:

Command to download and install homebrew
ruby -e "$(curl -fsSL\
    https://raw.githubusercontent.com/Homebrew/install/master/install)"
like image 184
sideshowbarker Avatar answered Sep 22 '22 15:09

sideshowbarker


I think looking at the man page the verbose flag is GNU only. Unfortunately, OSX implementation simply differs.

like image 31
TJ1S Avatar answered Sep 25 '22 15:09

TJ1S