Questions tagged [ls]

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

Filter by
Sorted by
Tagged with
1734 votes
10 answers
1.5m views

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

How can I sort the output of ls by last modified date?
user avatar
285 votes
6 answers
316k views

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 ...
Jimm Chen's user avatar
  • 5,904
238 votes
5 answers
263k views

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 ...
user155695's user avatar
  • 3,619
170 votes
10 answers
628k views

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
user avatar
161 votes
3 answers
8k views

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 ...
kirelagin's user avatar
  • 2,892
119 votes
12 answers
118k views

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's user avatar
  • 1,317
102 votes
8 answers
61k views

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 ...
xon1c's user avatar
  • 1,121
102 votes
4 answers
63k views

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 ...
Chris's user avatar
  • 1,238
80 votes
9 answers
69k views

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's user avatar
  • 9,063
69 votes
3 answers
121k views

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) ...
Armen Michaeli's user avatar
66 votes
8 answers
27k views

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-...
clang1234's user avatar
  • 887
56 votes
8 answers
141k views

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's user avatar
  • 969
48 votes
7 answers
93k views

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's user avatar
  • 2,534
47 votes
7 answers
71k views

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‐...
nelaaro's user avatar
  • 13.6k
39 votes
4 answers
35k views

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 -...
bguiz's user avatar
  • 2,091
34 votes
1 answer
6k views

Why does the `ls` command sort files like this?

As I was trying to reverse engineer the ls command, I came upon an interesting behavior. When I make 3 files, foo.png, foopa.png, and fooqa.png, ls sorts them as foopa.png, foo.png, and fooqa.png. I ...
mooncat39's user avatar
  • 341
31 votes
1 answer
33k views

Why ls and du show different size?

I am downloading a file with rtorrent, When I check the folder that the file is located on, the filesize with ls command is 4.4GB but when I check the disk with du command it shows me 219MB, also the ...
user24263's user avatar
  • 626
31 votes
1 answer
31k views

Why does ls wrap some filenames in single quotes?

I've noticed that when I do ls in a terminal, some filenames are wrapped in single quotes and some aren't. I don't like the way this looks as I prefer my terminal outputs to be nice and uniform. ...
Hashim Aziz's user avatar
  • 12.8k
30 votes
8 answers
95k views

Tell `ls` to print only the base filename

This is the default behaviour of ls ls /net/nas/data/languages/pypm/sites/rex/free/2.6/*/pool/v/vi/virtual*1.4.4*pypm /net/nas/data/languages/pypm/sites/rex/free/2.6/linux-x86/pool/v/vi/virtualenv-1....
Sridhar Ratnakumar's user avatar
30 votes
3 answers
38k views

What is the meaning of 'T' in the execution permissions of a directory?

I just found this confusing output of the ls command: whodare@ubuntu~ $: ls -l /var/spool/cron/ total 12 drwxrwx--T 2 daemon daemon 4096 Oct 29 05:02 atjobs drwxrwx--T 2 daemon ...
user avatar
29 votes
2 answers
32k views

How do I interpret the results of the `ls -l` command?

I want to learn about the meaning of values for example first line; drwxr-xr-x 2 ataka root 4096 2008-11-04 16:58 ataka is ataka here the owner of directory ? kioutsovkm@orkide:/users/lnxsrv2/ee$ ...
user avatar
25 votes
2 answers
34k views

How do I limit the number of displayed lines through ls?

Let's say I have a command ls -Bgclt /somwhere/in/the/past How do I limit the output to show me only first 2 files? (except for having only 2 files in that directory)
Denys S.'s user avatar
  • 490
24 votes
3 answers
41k views

Show both ctime and atime in ls output

Can I get both ctime and atime in ls output? Seems I can only pass one --time=ctime or --time=atime argument (the second is ignored). Is there any other way?
ibz's user avatar
  • 509
24 votes
1 answer
11k views

How to use wildcards with ls without listing directory contents?

ls typically displays only the files and folders in the present directory. But once you add a wildcard it starts searching in sub-directories. example: $ ls fight_folder file1 file2 $ ls f*...
Igorio's user avatar
  • 748
23 votes
2 answers
8k views

What is the magic separator between filenames in ls output?

The output of ls (with no arguments) appears to separate filenames with linebreaks. Evidence: ls | grep foo works as expected, with grep treating each filename as a separate line of input. ls > ...
Chris B's user avatar
  • 333
23 votes
2 answers
52k views

what does it mean a red filename shown with black background?

I have a compilation problem, and when I check my lib/ directory I get this output from "ls": What the red/black combination mean? I checked in the output of "dircolors -p" as suggested here (What ...
rmbianchi's user avatar
  • 333
23 votes
3 answers
32k views

What does the number after Unix/Linux file permissions like "-rw-rw-r--. 1 " mean in "ls -l" output

Can any one explain -rw-rw-r--. 1 and give some "detailed" information on ls -lart command. Specifically, what does the number 1 after the file permissions mean? Why does it change or why is it ...
VAR121's user avatar
  • 359
23 votes
0 answers
28k views

ls -la symbolics... what does that last symbol mean?

Possible Duplicate: what does the @ mean on the output of ls on os x terminal? when I type ls -la I get this familiar output... drwxr-xr-x+ 38 kent staff 1292 Nov 6 11:09 . drwxr-xr-x ...
user17047's user avatar
  • 331
22 votes
3 answers
17k views

Recursive ls with conditions

Why can't I use a command like this to find all the pdf files in a directory and subdirectories? How do I do it? (I'm using bash in ubuntu) ls -R *.pdf EDIT How would I then go about deleting all ...
Tomba's user avatar
  • 395
20 votes
2 answers
5k views

What does the first dash mean in an ls -l output?

From the bash man pages about viewing permissions with ls: User ls output Owner -rwx------ Group ----rwx--- Other -------rwx That makes sense, but what is the first - used for then? It's ...
David says Reinstate Monica's user avatar
19 votes
7 answers
31k views

Run an ls without getting the full path

I want a simple list of files in a directory that is not my current directory. I run ls /other/directory/*.txt and get: /other/directory/file1.txt /other/directory/file2.txt I want: file1.txt ...
User1's user avatar
  • 9,342
19 votes
2 answers
15k views

What does the @ in ls -al mean? [duplicate]

Possible Duplicate: ls -la symbolics… what does that last symbol mean? What does the @ in the below execution of ls -al mean? atom:Lib fak$ ls -al total 1056 drwxr-xr-x 5 fak staff ...
Frank Krueger's user avatar
18 votes
9 answers
41k views

How to produce a Linux-like `ls` output in Powershell?

I don't want the output of ls(Get-ChildItem) to be vertical (one file one line) in Powershell. I want it to be horizontal (like a table in Linux). After searching the web I don't know how to do that. ...
Shuai's user avatar
  • 283
18 votes
5 answers
16k views

How to list files recursively and sort them by modification time?

How do I list all files under a directory recursively and sort the output by modification time? I normally use ls -lhtc but it doesn't find all files recursively. I am using Linux and Mac. ls -l on ...
qazwsx's user avatar
  • 8,889
17 votes
3 answers
44k views

ls -rt (How to list just THE LAST file? e.g. for: | xargs gnome-open)

e.g. directory containing jpeg files: how to easily open just the most recent jpeg in the current directory?
ajo's user avatar
  • 915
17 votes
2 answers
87k views

List files of folder page by page with LS command

I'm wonder if there is some way to list all files of a folder by ls, I know how to use ls for a folders which are small but if list of files doesn't match with the screen size what should I do? there ...
Reza Ameri's user avatar
16 votes
4 answers
18k views

List file range with UNIX wildcards

Say for example I have the following files in my working directory: mjk0001.fits, mjk0002.fits, ... numerically increasing all the way to mjk9999.fits. Is there a way to use UNIX wildcards to list or ...
MJK's user avatar
  • 163
16 votes
3 answers
8k views

Bash: ls * without folder grouping

If I type: ls source/* source/fonts: fontello source/images: bg1.png eng.png fra.png I get the list of files, grouped by folder names. How can I simply get the list of ...
Augustin Riedinger's user avatar
16 votes
5 answers
57k views

How to list files sorted by owner in Unix?

I need to list the files in my current directory sorted alphabetically by the file owner name. Does ls have a way to do this?
user avatar
15 votes
6 answers
83k views

how to list all files and directories in given directory with full path but not recursive?

Somehow like dir /b command but I need also hidden and system files there. Built in dir command doesn't allow to list such 'hidden' files with the rest and I must use /s to have full path in there, ...
rsk82's user avatar
  • 1,452
15 votes
2 answers
44k views

How to `ls` a remote folder?

This one uses Samba: $ ls smb://192.168.5.4/wdtvlivehub/abc ls: cannot access smb://192.168.5.4/wdtvlivehub/abc: No such file or directory I somehow managed to do it by; Browsing to the remote ...
octosquidopus's user avatar
13 votes
4 answers
26k views

Filter ls output based on file size

I want to filter the output of the ls command based on file size. Any .jpg or .png files greater than 100KB should be reported in the output. I've been able to filter the .png / .jpg files, but I'm ...
smokinguns's user avatar
  • 1,428
13 votes
1 answer
7k views

Making ls aware of "hidden" file flag

Is it possible to make ls aware of the hidden file flag on Mac OS X? Currently, a simple ls -lO produces: $ ls -lO total 0 drwxr-xr-x@ 84 danielbeck staff - 2856 29 Mai 22:44 Applications ...
Daniel Beck's user avatar
  • 110k
13 votes
3 answers
5k views

How to physically reorder files `03.mp3 01.mp3 02.mp3` (`ls -f`) in a directory?

The physical order of the files matters when I copy them onto my USB stick and listen in car mp3 player. Most of my music album folders are unsorted, e.g. ls -f may produce: 03.song3.mp3 01.song1.mp3 ...
ajo's user avatar
  • 915
12 votes
2 answers
57k views

Vi can write to file despite file being read-only

The following example show how to create a file with only read permissions. As we can see, when I try to write to this file using the echo command I get, Permission denied. But why, in the case that ...
maihabunash's user avatar
12 votes
1 answer
6k views

Ubuntu's ls can show unicode characters, but tree cannot, even with tree --charset unicode

Ubuntu 10.04's ls can show unicode characters, but tree cannot, even with tree --charset unicode or utf8. Is there a way to solve it. echo could interpret the escape characters except cat list.txt | ...
nonopolarity's user avatar
  • 9,646
11 votes
3 answers
1k views

What does third symbol in "rw-" file mode mean in OS X ls manual page?

I have trouble understanding ls's manual regarding a file that has rw- mode. Here's the quote: If r, the file is readable; if −, it is not readable. If w, the file is writable; if −, it is not ...
Max Yankov's user avatar
11 votes
1 answer
26k views

ls | grep | rm -- How to format this command?

I'm trying to delete a bunch of files in a certain directory (on Mac OS X using Terminal) ls | grep \([1-9]\) | xargs rm should do the trick, but it doesn't. I'm trying to delete any file with a ...
Jeff's user avatar
  • 642
11 votes
5 answers
38k views

Recursively list full absolute path of files with permissions in Linux

I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
Michael Plautz's user avatar
11 votes
1 answer
11k views

Linux: ls -l prints only question marks:

I have a problem with listing of some directory with ls -l: $ ls -l ./directory -????????? ? ? ? ? ? file001.txt -????????? ? ? ? ? ? file002.txt and just ls works good: $ ls ....
osgx's user avatar
  • 6,847

1
2 3 4 5
7