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

learn more… | top users | synonyms

37
votes
4answers
17k 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 ...
35
votes
10answers
104k 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 ...
28
votes
2answers
7k 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 ...
21
votes
8answers
24k 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 ...
19
votes
10answers
50k 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 ...
19
votes
5answers
10k 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 ...
17
votes
4answers
111k 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 ...
17
votes
3answers
15k 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?
14
votes
4answers
6k 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 ...
12
votes
6answers
37k 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 ...
12
votes
3answers
21k 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?
12
votes
2answers
1k views

What are = and | in the output of “ls -F”?

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; = ...
11
votes
2answers
3k 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 / ...
9
votes
2answers
8k 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 ...
9
votes
2answers
1k 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?
9
votes
5answers
4k 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.
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
2answers
6k 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 ...
7
votes
2answers
3k 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 ...
7
votes
3answers
141 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
2answers
3k 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 ...
7
votes
3answers
506 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
16k views

How can I direct a pipe input to ls command?

When I type sth. like that find . -name *foo* | ls -lah it gives me a ls-output of 'pwd' like I had no file(s) given to 'ls'. To simply use ls -lah $( find . -name *foo* ) works well (when the ...
7
votes
3answers
3k 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
1answer
364 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
779 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
3answers
567 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
2answers
7k 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. ...
6
votes
3answers
4k 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 ...
5
votes
6answers
38k 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 ...
5
votes
2answers
6k 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 ...
5
votes
2answers
374 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
4k 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/ .... ...
4
votes
6answers
9k 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 ...
4
votes
4answers
2k 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, ...
4
votes
1answer
359 views

Nautilus sort order with ls

I am creating image sprites and have neatly named around 100 files. I am using the following to generate an image sprite from individual images: convert $(ls -w 1000) +append sprite.png I have just ...
4
votes
1answer
2k views

Why does ls -lh give me ls: invalid option — 'h'

I'm using Interpid (I know I need to upgrade). When I try and use the -h option with ls I get an error. I swear this used to work, and the man page says it should. Any ideas? $ sudo ls -lh ls: ...
4
votes
3answers
1k views

create a list of files located in multiple directories

I have a set of data files (*.all) located in different folders Documents/rawdata/Geob1005/1.all, 2.all, 3.all,...,n.all Documents/rawdata/Geob1006/A.all, B.all, C.all,...,Z.all and so ...
4
votes
1answer
907 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 ...
3
votes
7answers
7k 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 ...
3
votes
2answers
764 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 ...
3
votes
2answers
364 views

“ls” with one-digit pattern gives me strange results

I'm running Ubuntu as VM in VMWare Fusion on MacPro: ayakovlev@ubuntu:~$ uname -a Linux ubuntu 3.11.10.3 #1 SMP Thu Mar 6 15:31:54 EST 2014 x86_64 x86_64 x86_64 GNU/Linux The command below outputs ...
3
votes
2answers
104 views

locate command finds a file's path, but the file does not exist in that path [duplicate]

I have written: locate Origin90SR2DVD.iso And I received the path where that file is located: /home/david/Origin90SR2DVD.iso Then I have written: cd /home/david I have run: ls -lrth And ...
3
votes
1answer
209 views

Strange terminal navigation when logged in as new user

I am not even sure how to ask this properly.. I am using EC2 Ubuntu 12.04 I added a new user sudo useradd -g admin admin sudo adduser admin sudo Changed shudders so I can use new user without ...
3
votes
1answer
3k views

Using alias to change ls to ls-l changes(or disables) the colors of ls output

I've used alias to change ls to ls -l, but the colours change to the normal font of the terminal (also tried ls -l before the alias command and the colours appeared fine). What is wrong? Thank you
3
votes
2answers
1k views

ls on home directory very slow

A while ago, I accidentally created hundreds of thousands of files in my home directory which I subsequently deleted. Since then however, running ls in my home directory has been extremely slow ...
3
votes
1answer
230 views

Directory permission

I am running 12.04 x64 server on ext4 disk. There are two user groups 'A' and 'B'. For a specific directory, I would like to give its all permissions to user group 'A'. Also I would like to give only ...
2
votes
4answers
102 views

how can I List files in order

I had an 18GB file I needed to download on a less than great Internet connection. Torrenting wasn't an option. So I busted up the file into 100 segments, and eventually, all of it downloaded. Now I ...
2
votes
3answers
6k views

List files of particular extension

Ok this is strange. I am using this code, ls *.prj To list all the files with the .prj extension in the dir but I am getting this error, bash: /bin/ls: Argument list too long I eventually ...
2
votes
1answer
50 views

Why does 'echo *' give different results than 'ls *'?

For example, if you are in home directory and type ls *, you will have all the directories listed, and below the name of the listed directory, the files that it contains. On the other hand, if you ...