Questions relating to the Linux 'list' command (ls)

learn more… | top users | synonyms

53
votes
9answers
168k views

How to move multiple files at once to a specific destination directory?

I got a bunch of files in some directory (along with many other files) that I want to move. Luckily, all the files I want to move contain a certain identifier in their names, so I can ls | grep ...
44
votes
4answers
27k views

Difference between 'dir' and 'ls' terminal commands?

I've been trying to find the difference between using the dir and ls commands in terminal. I know ls is the traditional unix method of viewing the files in a directory, and that dir is the windows ...
42
votes
3answers
79k views

How do I change the color for directories with ls in the console?

On my console the color for directories is such a blue, that it is hard to read on a dark background. How can I change the color definitions for ls?
40
votes
3answers
232k views

How to Search for Files Recursively into Subdirectories

I am trying to look for all XML files in a particular directory and all sub-directories (recursively) inside it. ls -R *.xml is only listing files in the current directory. I am quite sure, the sub-...
37
votes
10answers
114k views

How to show only hidden files in Terminal?

I have a directory that contains thousands of files, some of them are hidden. The command ls -a list all files, including hidden ones, but I need just to list hidden files. What command should I use?...
30
votes
7answers
119k views

How to list all symbolic links in a directory

I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all ...
30
votes
2answers
10k views

Why does ls -l output a different size from ls -s?

I can't figure out why I'm getting the following results: ls -l tells me the size of a given file (HISTORY) is "581944": $ ls -l HISTORY -rw-rw-r-- 1 waldir waldir 581944 Feb 22 10:59 HISTORY ls -...
26
votes
7answers
4k views

Why doesn't the command “ls | file” work?

I've been studying about the command line and learned that | (pipeline) is meant to redirect the output from a command to the input of another one. So why does the command ls | file doesn't work? ...
26
votes
2answers
3k views

Why do I get a train when I run 'ls'?

I have recently noticed something odd that I don't like very much: So why am I getting a train upon running ls? And how can I stop this and make it behave normally? Is this an Easter Egg that I ...
25
votes
9answers
38k views

How to list all the files in a tree (a directory and its subdirs)?

For a task of mine I need to list all the files in a tree (a directory, all its subdirs, all subdirs of those, etc.). I'd prefer to see them in Nautilus or Krusader, but a command-line solution is ...
22
votes
5answers
12k views

In the output of 'ls -n', what does the the second column mean?

When I run: ls -n I get something like: -rwxrwxrwx 1 1000 1000 765528 2009-10-15 18:41 file1 drwxr-xr-x 10 1000 1000 4096 2010-12-07 20:50 dir1 drwxr-xr-x 3 1000 1000 4096 2010-10-24 ...
19
votes
2answers
3k views

How does ls -l format its output so neatly?

How does ls -l format its output so that column contents line up neatly?
19
votes
3answers
22k views

How to activate pagination for ls command?

What is the equivalent option for the ls command to activate pagination as in DOS the dir /p does?
18
votes
4answers
12k views

What is the significance of '*' (star, asterisk) in the file listing results?

I have noticed that some of my files have an asterisk at end. Does the asterisk at the end have any particular significance? I think they are mostly executable and displayed in green by the ls ...
13
votes
2answers
21k views

exclude certain files in ls

I would like to run ls and exclude certain files in the output. When I run the following command, I get all files with each on one line: $ ls -1 file1 file2 file3 temp I would like to run this ...
13
votes
1answer
2k views

What do the symbols like =, * and | in the output of “ls -F” mean?

I am working on creating a 'cheat sheet' of shell commands. I am currently researching the ls command and its flags. For the -F flag I know what the majority of the appended indicators mean but for; = ...
12
votes
2answers
2k views

What does the l command do?

There is a command l available on my machine which appears to do nothing. which l also produces no output. Is this a real command, and does it actually do anything?
12
votes
1answer
760 views

What are those 'x xx' in 'ls -l' command

When performing ls -l I encountered a column I don't recognize. drwxrwxr-x 7 user user 4096 × ×× 29 13:54 .eclipse drwxrwxr-x 3 user user 4096 × ×× 30 09:30 workspace drwxrwxr-x 3 user ...
11
votes
5answers
7k views

How to find all PDF files in directories and their subdirectories?

I want to list all PDF files in the directories of the current working directory. What command can do this? I remember a combination of ls and */*.pdf but don't remember what exact combination.
11
votes
2answers
5k views

What is the double slash (//) directory?

I mistakenly typed cd // instead of cd /. To my surprise, current directory showed up as //. What is that directory? Why does it exist? apple@snipped $ pwd /home/apple apple@snipped $ cd / apple@...
10
votes
2answers
7k views

Difference between ls -l and ll?

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but is ...
10
votes
3answers
23k views

How can I direct a pipe input to ls command?

When I type something like: find . -name *foo* | ls -lah it returns the same result as a plain ls command, as though it had no input. However: ls -lah $( find . -name *foo* ) works well, but ...
10
votes
2answers
10k views

Best way to list 100 first files in a directory sorted by time

What would be the best way to list 100 first files in a directory sorted by the created timestamp (oldest first). The directory is quite large (around 100000 files). ls piped to head takes an awful ...
9
votes
3answers
1k views

Tell `ls` to sort by regular ASCII codes, not “intelligently”

I have a couple files and ls sorts them like this: a _b c but I want to have _b a c How can I do that?
8
votes
6answers
66k views

listing files in a directory without listing subdirectories and their contents in that directory

I want to create a list of all the files in a directory, without listing any of the subdirectories that reside in that same directory, and print that list to a new file. ls -d * > filelist will ...
8
votes
2answers
5k views

List all files that do not have extensions

I want to list all files in a directory that don't have extensions. For example: $ ls a.txt b c.pdf d e.png $ ls -someOption b d What command I can use instead of ls -...
8
votes
3answers
4k views

Can ls -l be made to separate fields with tabs rather than spaces to make the output useful in a spreadsheet?

How can the output of ls -l be modified to separate fields using tabs instead of spaces? I want to paste the output into a spreadsheet; the padding with a variable number of spaces makes it difficult ...
7
votes
7answers
29k views

Count total number of files in particular directory with specific extension

I want to count the total number of files in particular directory that ends with ".mp4" extension. I am getting following command: ls -F |grep -v / | wc -l It count all the files in particular ...
7
votes
4answers
916 views

List all recently changed files (recursive)

So, I want to display (via ls for example) all files, which were changed in the last seven days. If I'm in my docroot-folder, it should be able to look "deeper". For example: File Last ...
7
votes
3answers
155 views

List files appended with an order number

Is there a quick way to list all the files from a location having an appended order number? something like: ls -a generates the result: 1 file a 2 file b ... 100 file whatever Thanks. P.S. ...
7
votes
3answers
2k views

What does the “size” of a symlink represent in ls output?

I'll start by example: $ ls -l dir1 total 4 -rw-r--r-- 4 maythux maythux 1650 2008-01-10 16:33 file lrwxrwxrwx 1 maythux maythux 7 2008-01-15 15:17 symfile -> file symfile is a symlink of the ...
7
votes
3answers
832 views

Listing files with grep?

I have a directory that contains the following files: file1a file1ab file12A2 file1Ab file1ab I want to list all files that start with file1 and followed by two letter at most! The solution I ...
7
votes
3answers
6k views

change default command options

When I enter command ls I see a list of files and directories in current directory, the list displayed is quite annoying. Rather, I like to execute ls command with -1 option like ls -1 My ...
7
votes
1answer
451 views

automatically run ls after changing path using autocd

So everytime I change the directory I would like the new path to automatically get listed with ls.There are solutions if the path gets changed using cd but I never found a solution that would work ...
6
votes
1answer
1k views

ls command is only showing files, and no folders (spaces? instead of them)

Today I typed ls command in my home directory, and it only showed "examples.desktop" and not the folders. But in the past, it showed all the folders like Documents and Downloads. What is the problem ...
6
votes
4answers
361 views

is there ls -l numeric formating?

consider the output of this ls -l command: $ ls -l /usr/bin | tail -rwxr-xr-x 1 root root 105696 Oct 25 2014 zenity -rwxr-xr-x 1 root root 188296 Oct 21 2013 zip -rwxr-xr-x 1 root root ...
6
votes
3answers
10k views

Why doesn't this wildcard work the way I expect?

On my user folder, I have folders like D ropbox, D ocuments, D ownloads & d ump. ls a* should list all the files whose name starts with a. Right? But when I gives the command ls d*, instead of ...
6
votes
3answers
797 views

How do you get details from the output of the locate command?

When I run the ls -l command I get details about the files in the current directory like permissions, owner, group, file size. Is there a way I can get these same details instead of just the ...
6
votes
4answers
13k views

How to list text files without a .txt file extension?

For example, how can I replicate: ls *.txt when my text files are missing the .txt ending, and as far as extensions go appear the same as many other types of file? Alternatively, is it possible to ...
6
votes
2answers
8k views

Is there a way to do a ' ls -R | grep “aname”* | rm; to remove multiple files in multiple directory

I have installed (compiled) emerald. The command make uninstall didn't work (there is no makefile as it is just a script). So I decided to remove the file manually. But there were a lot of files. I'...
5
votes
3answers
814 views

found ls binary using whereis but can't find ll why?

found ls binary using whereis but can't find ll why ? How to find where ll binary loacted ? I found "ls" binary using "whereis" but can't find "ll" $ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1....
5
votes
7answers
9k views

How to enter every directory in current path and execute script

I want to enter every directory retuned by ls command and execute script. I tried this (and many other things), but it just does not work ls | awk '{print $1" && pwd"}' | xargs cd How to ...
5
votes
2answers
1k views

How to make ls produce ISO 8601 format

In older versions of Ubuntu, like 9.10, ls(1) produced ISO 8601 format by default, in the way ls -l --time-style=long-iso does it. With 12.04, we're back at the older Unix style. Thus replacing ...
5
votes
2answers
476 views

Colorize hardlinks in ls output?

How can I colorize hardlinks myself? Turns out on an old Ubuntu 10.04 I have, this happens by default (same .bashrc and .profile in use), whereas on the newer Ubuntu 12.04 it doesn't. This is the ...
5
votes
4answers
6k views

Can I use ls -R to show up to 2 folder depth?

I have a folder tree that looks like this main/ main/34532-23423632-2354/what-i-want/sth/other/blah-blah main/54634-56345634-3422/what-i-want/sth/ .... main/...
5
votes
4answers
3k views

What's the easiest way to remove the “total <size>” line from the output of ls -l?

The best I could find via Google/man ls was: ls -l | grep -v '^total' Is there something I'm missing in the flags to ls? Also, why is the total size in kb, regardless of the -h flag? scratch that, ...
5
votes
1answer
1k views

Summarize file sizes of a directory structure?

I have written a small backup script with rsync. I would like to monitor its progress by comparing the total file sizes on the source and destination directories. du Is inaccurate because it measures ...
4
votes
2answers
4k views

What does 'ls -la' do?

When I entered the -al attribute with the ls command, I got the following: anupam@JAZZ:~/blog$ ls -al total 76 drwxrwxr-x 13 anupam anupam 4096 Aug 28 21:45 . drwxr-xr-x 34 anupam anupam 4096 Aug 28 ...
4
votes
2answers
3k views

What does each part of the `ls -la` output mean? [duplicate]

What do the following numbers represent?
4
votes
3answers
549 views

Size of device file ( missing in ls -l output )

When I try to print the device file output shows binary data in hexadecimal format. But upon doing a ls -l /dev/sda I get: brw-rw---- 1 root disk 8, 0 Jan 29 12:29 /dev/sda I don't ...