Questions tagged [ls]

The command to list the contents of a folder/directory in Unix and Unix-like systems.

ls is short for "list," which when used in Unix or Unix-like operating systems will display a list of files.

Options can be added in order to change the way this command works or how it displays the information back to the user.

The Windows counterpart of ls is , or in , Get-ChildItem.

327 questions
1717
votes
10 answers

How can I sort the output of 'ls' by last modified date?

How can I sort the output of ls by last modified date?
nearly_lunchtime
275
votes
6 answers

How to have Linux ls command show second in time stamp

Something annoying about ls -l command is it shows only hour and minute for a file(like 08:30). How can I see the second portion(like 08:30:44)? man 1 ls and search for 'second' does not give any clue.
Jimm Chen
  • 5,702
  • 6
  • 31
  • 40
235
votes
5 answers

What does the asterisk mean after a filename when you type `ls -l`?

I've done an ls -l inside a directory, and my files are displaying like this : james@nevada:~/development/tools/android-sdk-linux_86/tools$ ll total 9512 drwxr-xr-x 3 james james 4096 2010-05-07 19:48 ./ drwxr-xr-x 6 james james 4096…
user155695
  • 3,559
  • 11
  • 33
  • 34
170
votes
10 answers

ls-command: how to display the file size in megabytes?

In Unix (Tru64), how do I make the ls command show the file size in megabytes? Currently I am able to show it in bytes using the following: ls -la
atricapilla
161
votes
3 answers

On OS X, why does `sudo ls` show hidden (dot) files?

With OS X Yosemite, using the following commands, I get the following: $ touch .a $ touch b $ /bin/ls b $ /bin/ls -A .a b $ sudo /bin/ls .a b It shows hidden files (that have names starting with a dot) when invoked by root and doesn’t show them…
kirelagin
  • 2,832
  • 2
  • 17
  • 22
116
votes
12 answers

How to sort first directories then files etc… when using “ls” in Unix

I would like to use the ls command to first show directories and then files. I tried: ls -la | sort -k 1 But I got a wrong order.
atricapilla
  • 1,287
  • 3
  • 13
  • 14
101
votes
4 answers

Icon? file on OS X desktop

When I ls my Desktop from terminal (by using ls ~/Desktop), I see a file named Icon?. As far as I can tell, it's empty (nano Icon? shows nothing). It doesn't show up on my actual Desktop, and open Icon? shows the Finder alert This item is used by…
Chris
  • 1,228
  • 2
  • 11
  • 13
100
votes
8 answers

What does the @ mean on the output of "ls" on OS X' terminal?

When doing an ls in a directory I get the following output: drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 Mai 23:04 .DS_Store -rw-r--r--@ 1 xonic staff …
xon1c
  • 1,101
  • 2
  • 8
  • 4
80
votes
9 answers

How do I get ls --color=auto to work on Mac OS X?

I'm trying to move my bash configuration from Ubuntu to Mac OS X and it looks like ls is slightly different. For instance, it won't accept the --color option. How do I get this to work?
cfischer
  • 8,973
  • 11
  • 37
  • 42
66
votes
3 answers

How to make `ls` color its output by default, without setting up an alias?

I don't want an alias (alias ls='ls --color'), and I had previously set this up on Mac OSX using CLICOLOR environment variable which magically brought colors to ls. Now I am on Linux (Arch x86-64) with xterm and a really basic setup, and I can't…
Armen Michaeli
  • 2,452
  • 8
  • 32
  • 42
64
votes
8 answers

How can I make "ls" show dotfiles first?

Somewhere along the way I screwed up my ls command and now I get this ordering when running $ ls -AhHl --color=auto -rwxr-xr-x 1 clang clang 640 Mar 1 02:46 apple-touch-icon-precomposed.png -rwxr-xr-x 1 clang clang 784 Jul 12 02:54…
clang1234
  • 867
  • 2
  • 10
  • 12
56
votes
8 answers

How to list folders using bash commands?

Is there any way to list just the folders in a directory using bash commands? ( as the ls command lists all the files and folders )
SpiXel
  • 969
  • 3
  • 10
  • 14
47
votes
7 answers

The command 'ls -d' is not displaying directories. Is there a way to get 'ls' to only display directories instead of files and directories?

Is there a way to get ls to only display directories instead of files and directories? From the man page: -d, --directory list directory entries instead of contents, and do not derefer‐ ence symbolic links So if I type it at…
nelaaro
  • 13,149
  • 30
  • 84
  • 111
46
votes
7 answers

How can I list only non-empty files using ls?

How can I list (using ls) all files that are not empty (size > 0) using linux?
David B
  • 2,454
  • 7
  • 27
  • 33
38
votes
4 answers

How to diff file names in two directories (without writing to intermediate files)?

I am trying to do something along the lines of: diff `ls -1a ./dir1` `ls -1a ./dir2` But that doesn't work for obvious reasons. Is there a better way of achieving this (in 1 line), than this? ls -1a ./dir1 > lsdir1 ls -1a ./dir2 > lsdir2 diff…
bguiz
  • 2,041
  • 5
  • 22
  • 33
1
2 3
21 22