Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

issues "using ls -al --full-time" in OSX [closed]

Tags:

--full-time is a handy little option for ls but it doesn't work when used in a batch file.

ls -al --full-time when used at the command prompt yields a an expanded date and time:

2012-01-16 18:56:00.000000000

used in a bash script I got this:

ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]

is there any way around this.

like image 751
C0ppert0p Avatar asked Mar 08 '13 04:03

C0ppert0p


People also ask

How do you use the ls command on a Mac?

While you're there—or when you're in any folder (directory in Unix-speak)—you might want to know what's in it. To do that you use the ls (or list) command. Type ls and press the Return key, and you'll see the folders (and/or files) in the current directory.

What does ls stand for in Terminal Mac?

The ls command is used to list files. "ls" on its own lists all files in the current directory except for hidden files.


2 Answers

for native ls command, option -T seems to be the alternative of --full-time, and it expands to seconds, example as below:

>$  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
like image 113
Peixu Zhu Avatar answered Sep 18 '22 11:09

Peixu Zhu


The BSD (Mac OS X) version of ls (installed as /usr/bin/ls) does not support the --full-time option.

The GNU version of ls does support --full-time. I have the GNU ls installed in a different directory (/usr/gnu/bin/ls).

  • Are you sure that you have GNU ls on your machine at all?
  • If so, are you sure your PATH includes the directory where it is installed ahead of /usr/bin when you run scripts?
like image 27
Jonathan Leffler Avatar answered Sep 22 '22 11:09

Jonathan Leffler