bash 在 OSX 中“使用 ls -al --full-time”问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15286749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
issues "using ls -al --full-time" in OSX
提问by C0ppert0p
--full-timeis a handy little option for lsbut it doesn't work when used in a batch file.
--full-time是ls 的一个方便的小选项,但在批处理文件中使用时它不起作用。
ls -al --full-timewhen used at the command prompt yields a an expanded date and time:
ls -al --full-time在命令提示符下使用时会产生扩展的日期和时间:
2012-01-16 18:56:00.000000000
2012-01-16 18:56:00.000000000
used in a bash script I got this:
在 bash 脚本中使用我得到了这个:
ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
ls: 非法选项 -- -- 用法: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [文件...]
is there any way around this.
有没有办法解决。
回答by Peixu Zhu
for native lscommand, option -Tseems to be the alternative of --full-time, and it expands to seconds, example as below:
对于本机ls命令, option-T似乎是 的替代--full-time,它扩展到秒,示例如下:
>$ ls -lT
-rw-r--r-- 1 raison staff 197 Feb 14 09:12:56 2013 1.c
-rw-r--r-- 1 raison staff 1174 Mar 8 09:34:49 2013 1.s
-rw-r--r-- 1 raison staff 993 Feb 5 14:44:09 2013 1.x86.s
回答by Jonathan Leffler
The BSD (Mac OS X) version of ls(installed as /usr/bin/ls) does not support the --full-timeoption.
BSD (Mac OS X) 版本ls(安装为/usr/bin/ls)不支持该--full-time选项。
The GNU version of lsdoes support --full-time. I have the GNU lsinstalled in a different directory (/usr/gnu/bin/ls).
的 GNU 版本ls确实支持--full-time. 我将 GNUls安装在不同的目录 ( /usr/gnu/bin/ls) 中。
- Are you sure that you have GNU
lson your machine at all? - If so, are you sure your PATH includes the directory where it is installed ahead of
/usr/binwhen you run scripts?
- 你确定
ls你的机器上有 GNU吗? - 如果是这样,您确定您的 PATH 包含
/usr/bin在您运行脚本之前安装它的目录吗?
回答by phs
$ uname -rs
Darwin 11.4.2
$ ls -al --full-time
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
Are you sure your lsisn't actually glsinstalled by homebrew?
您确定您ls实际上不是gls由自制软件安装的吗?

