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

learn more… | top users | synonyms

357
votes
7answers
227k 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? I can't find the answer on Google without digging around, an there is no answer on Stack Overflow either.
39
votes
6answers
43k 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 )
32
votes
8answers
21k views

Unix: ls, how to sort first directories then files etc

I would like to use ls command to first show direcotries and then files. I tried ls -la | sort -k 1 But I got a wrong order.
30
votes
2answers
6k views

Icon? file on OS X desktop

When I ls my Desktop from terminal (by using ls ~/Dekstop), I see a file, 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? ...
27
votes
5answers
27k views

what does the asterisk mean after a filename if you do 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 ...
23
votes
7answers
5k 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 ...
23
votes
0answers
20k 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 . ...
21
votes
4answers
12k 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?
18
votes
7answers
15k views

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 ...
18
votes
2answers
9k 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$ ...
16
votes
1answer
8k 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 ...
15
votes
2answers
1k 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 > ...
11
votes
2answers
8k 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)
11
votes
2answers
4k 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 ...
10
votes
2answers
7k 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 ...
9
votes
7answers
18k 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 ...
9
votes
0answers
9k views

what is the @ after the permissions for in ls -l on a mac? [duplicate]

Possible Duplicate: ls -la symbolics… what does that last symbol mean? Consider the following output from ls -l on OS X 10.5.8 drwxr-xr-x 3 user staff 102 Aug 26 20:21 ...
8
votes
1answer
12k 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 ...
7
votes
1answer
5k views

ls and du shows VERY different size!

I am downloading a file with rtorrent, But 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 ...
7
votes
1answer
3k 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 ...
6
votes
2answers
23k views

How to find all soft links (symbolic links) in current directory?

Question relates to shell-scripting in bash. How to check with a script which files within the current directory are soft links? In case I have used the wrong term, when I say soft links, I am ...
6
votes
2answers
594 views

Is there a tail -f equivalent for ls?

Basically the question is in the title. I want to monitor a directory for new files that are written or deleted, the way I can monitor a log file with tail -f. Is this possible?
6
votes
3answers
5k 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 ...
6
votes
2answers
137 views

What is the modification date ls reports for directories in Bash shell?

When I run ls -l in Bash shell, it lists a modification time for both files and directories. As noted in this thread, the modification time for directories does not reflect all of its contents. It ...
6
votes
2answers
1k 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 ...
6
votes
4answers
1k views

Pass the output of ls to diff

I have one file that contains a list of files from a server, and a local folder that I compare to that manifest. Obviously, I do 'ls -1 > listing_local' and then diff that file with listing_server. ...
6
votes
4answers
3k views

List files recursively and sort 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 ...
5
votes
7answers
11k 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?
5
votes
1answer
809 views

Mac OS X: Is there a straightforward way to color ls output according to Finder label colors?

I have a client with a directory tree that has a number of high-level directories that I need to have on my local development machine. I rarely look at them unless something goes awry. I've marked ...
5
votes
3answers
822 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 ...
5
votes
2answers
689 views

is there a way to read the cumulative size of all files in a folder?

I want to read the size of a folder from the command line. ls -lh shows all folders as being 4k, which presumably is the size of the footprint of the folder itself, rather than the contained files. ...
5
votes
3answers
5k 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 ...
5
votes
5answers
15k 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, ...
5
votes
1answer
574 views

What is the + at the end of Unix permissions in a long listing format?

Here's an example drwxr-xr-x+ 6 reza reza 204 Mar 5 20:23 .ssh/ Although I am the owner of this directory, I cannot modify it without using sudo! Why is that? how can I remove '+' here ...
5
votes
2answers
693 views

ls version number sorting Mac OS X

Is there an equivalent to ls -v in Mac OS X that will do version number sorting? In Mac OS X, ls -v does NOT do version number sorting, but the Finder seems to.
5
votes
2answers
1k views

How can I get colors with “ls -l | more”?

ls -l gives me color coded output. Folders are blue, executables green, etc. These colors are gone when filtering thorough | more. Anyway to achieve both paged output and colors?
5
votes
2answers
389 views

How to use GNU parallel with gunzip

I have a directory full of .gz, I want to expand each archive in parallel with GNU parallel. However I did not achieve anything. I tried parallel 'gunzip {}' ::: `ls *.gz` parallel gunzip `ls *.gz` ...
5
votes
1answer
301 views

Linux shows several folders with the exact same name

I recently used a mac to copy several files and folders to a USB drive (ext4 through ExtFS), and now in Linux (Xbian) two folders in the root of the drive are shown four times. The output of "ls ...
4
votes
4answers
4k views

How to rename multiple files in a directory in some pattern in Linux?

I have a directory which has files with random names. What I want to do is rename the files with file1, file2 and so on.The lexicographically smaller file name should be numbered with smaller number. ...
4
votes
3answers
3k 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 ...
4
votes
3answers
4k 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?
4
votes
4answers
610 views

How to turn off --classify option in ls command?

My ls command is aliased to have certain options automatically applied, including --classify (same as -F) Normally this is fine and I don't want to screw around with my .bashrc file. Just this one ...
4
votes
1answer
2k 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 | ...
4
votes
1answer
707 views

List files beginning with underscores first when using `ls -l`

I'm using ubuntu (natty), and when I use ls -l, the files are listed, but apparently the sorting algo ignores any special characters. For ages I've used underscores to mark special folders. And it ...
4
votes
2answers
1k 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 ...
4
votes
1answer
3k views

What does the + mean in the ACL output of “ls -l”?

ls -l -rwxr-xr-x 1 root root 885 2010-07-08 13:55 /etc/backup-number-of-files* -rwxrwxr-x+ 1 levchuk Users 1067 2010-08-30 14:37 /etc/backup-running-time* Please notice the + on the 2nd ...
4
votes
1answer
611 views

In ls, how can I remove bg color for sticky bit

How can I remove the background color for the sticky bit. LSCOLORS looks like this export LSCOLORS="Gxfxcxdxbxegedabagacad" Using oh-my-zsh Edit: As suggested I tested LSCOLORS="" ls but the colors ...
4
votes
1answer
43 views

Finding the newest file in a directory with a million files

I'm currently using ls -t | head -1 to get the name of the newest file. But it takes a long time because my directory has a million files. I guess a chunk of time is lost unnecessarily in ls -t when ...
4
votes
1answer
616 views

Why does `ls` without any arguments (only flags) give me “no such file or directory”?

When I pass --color=always to ls, it occasionally outputs a number of No such file or directory errors, like this: ~/svn/projects/submm/adda/scat$ /bin/ls --color=always ls: cannot access ...
3
votes
3answers
825 views

Is there a tool on Unix, Linux, Mac, Windows, Ubuntu, that will list file / directory structure?

I wonder if there is a tool that will list file / directory (i.e. take a snapshot of the folder and file structure) like the following: audio mp3 song1.mp3 some other song.mp3 audio books ...