Mac OS X /usr/bin/time verbose flag

早过忘川 提交于 2019-12-23 07:29:14

问题


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)?


回答1:


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)"



回答2:


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



来源:https://stackoverflow.com/questions/32515381/mac-os-x-usr-bin-time-verbose-flag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!