The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
3answers
1k views

Ls with spaces + variables

I want to do something like this, but it doesn't save the variable after the piping ends: fs=( ) echo ${fs[@]} ls -A1 | while read f do echo ${fs[@]} fs+=( "$f" ) echo ${fs[@]} done echo ...
9
votes
1answer
21k views

How can I assign the result of a command to a shell variable?

I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; ...
10
votes
7answers
37k views

How to list files without directories, and filter by name (ls options)

I have a directory called uploads. It contains a bunch of files, plus a few subdirectories which in turn contain files. Is there a way I can (in one step) do the following: List ONLY the files in ...
2
votes
1answer
2k views

Why can't list file/directory relative to .. from a symbolic link directory (No such file or directory)?

I have a /usr/tomcat6/logs directory linked to /var/log/tomcat6. When I changed directory to /usr/tomcat6/logs and try to ls files using a relative pathname ../conf/Catalina/localhost, a No such file ...
7
votes
2answers
1k views

Is there a correct way to list the subdirectories of the current directory?

I can find the subdirectories of a directory by ls -d -- */ or ls -l | grep "^d" but both of these seem indirect, and I would imagine that there would be a standard way to find just the ...
5
votes
1answer
4k views

ls: how do I list directories sorted by timestamps of the files it contains

How do I list directories by their access time in the sense that some new files/directories are created (say, directories containing the most recently created files).
3
votes
1answer
1k views

ls -a not showing folder “system”, but echo * shows it

When I create a folder named system in my home folder, or in /tmp (can't try other locations as I am not root, but owner confirmed same problem even on root), ls -a will not show it. Also tried ...
9
votes
4answers
2k views

What is the “directory order” of files in a directory (used by `ls -U`)?

According to the man page for ls, ls -U means: do not sort; list entries in directory order. What does "directory order" mean, and how is it determined? The following test (executed on an ...
10
votes
6answers
5k views

What does the “number” in the owner field of files signify in linux?

I copied many files to my new linux host. I see that all files have the owner and group both set to 515. What does that mean?
25
votes
1answer
2k views

Why does “ls *” take so much longer than “ls”?

I have a couple of files in a directory: $ ls | wc -l 9376 Can anybody explain why there is such a huge time difference in using ls * and ls? $ time ls > /dev/null real 0m0.118s user ...
6
votes
3answers
3k views

How do i open all files that are the result of a ls command?

I'd like to open all text files that are the result of a ls command using a text editor. How do i do this?
3
votes
2answers
516 views

Total in `ls -l`

When I run ls -l, the following is displayed: >: ls -l total 320 -rw-r--r-- 1 foo staff 633 5 Apr 13:23 A.class -rw-r--r-- 1 foo staff 296 5 Apr 13:24 A.java ... What does the ...
17
votes
11answers
3k views

Linux - command to list files (except ls)

Imagine you were working on a system and someone accidentally deleted the ls command (/bin/ls). How could you get a list of the files in the current directory? Try it. I tried many ...
16
votes
4answers
23k views

Why is Debian's root shell colorless?

Are there any security concerns? What is the best way to enable it?
3
votes
3answers
1k views

Really strange FAT32 file listing problem

I'm mounting a FAT32 drive on my NAS (which has a USB port), and hitting a strange issue when I use the ls command on the drive root: ls: cannot access ???²é?u.g: Input/output error ls: cannot ...
19
votes
2answers
8k views

Output from ls has newlines but displays on a single line. Why?

I think I may be overlooking a relatively fundamental point regarding shell. Output from the ls command by default separates output with newlines, but the shell displays the output on a single line. ...
18
votes
2answers
57k views

How to get only files created after a date with ls?

With ls command, does it possible to show only file created after a date, hour... I'm asking it because I have a directory with thousand of files. I want files created since yesterday. I use ls ...
6
votes
6answers
4k views

Compare files that are in directory 1 but not directory 2?

I'm having trouble with a bash script I want to make I know ls will list files that are in a directory but I want it to list directories that are in directory1 but NOT in directory2, and then list ...
15
votes
4answers
15k views

last time file opened

Is it possible to get the time when file was opened last time and sort all files in a directory by those times?
15
votes
3answers
15k views

Find the owner of a directory or file, but only return that and nothing else

I am looking for a command that will return the owner of a directory and only that--such as a regex parsing the ls -lat command or something similar? I want to use the result in another script.
3
votes
1answer
230 views

ls pagination on MontaVista with BusyBox

I'm logged into an IP Phone running MontaVista with a very stripped down BusyBox binary (by stripped down, I mean the OEM has removed almost all of its functionality, except the basics like cat, ls ...
11
votes
3answers
10k views

What is the Linux equivalent of DOS “dir /s /b filename”?

List all files/dirs in or below the current directory that match 'filename'.
4
votes
2answers
2k views

Scrolling through ls output without a mouse

In some directories there are quite a few files. When I use ls the output is more than my terminal can handle. Typically I just use one of the following: ls | less ls | more depending on my mood. ...
2
votes
2answers
307 views

Is it possible to change the spacing between files using ls

I'm fairly new to unix and I was wondering if there's some attribute of ls that I can use to change the spacing between the files. Currently I've aliased my ls to output ls -G, so that I have colored ...
4
votes
2answers
1k views

How can I search for a file with fixed name length using ls?

In a directory, I have files like lazer_100506 lazer_100707 lazer_091211 lazer_110103 lazer_100406_temp lazer_100622#delete etc How can I get a listing of only the first four files? $ ls ...
4
votes
1answer
293 views

Set ls color listings based on regex instead of globbing

Is it possible to set regex patterns for color matching in the LS_COLORS variable? So instead of just *.jpg=38;5;220 Can I do \.(jpg|gif)=38;5;220 That's just an example, I'd like to get more ...
14
votes
5answers
7k views

What is the difference between ls and l?

I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is ...
19
votes
3answers
3k views

ls command: what does the first line mean?

When I do ls -l I get this: calico@A000505:~/Documentos$ ls -l total 2020 -rwxr-xr-x 1 calico calico 8559 2010-11-16 11:12 a.out -rwxrw-rw- 1 smt smt 2050138 2010-10-14 10:40 Java2.pdf ...
5
votes
3answers
5k views

list full path of file without tying it from relative relative path

I could do this root@server [/home/user/public_html]# ls /home/user/public_html/.htaccess but I'd like to do this ls --switch .htaccess /home/user/public_html/.htaccess is it possible?
2
votes
1answer
3k views

Find the disk-space usage of a directory and all it's files [duplicate]

Possible Duplicate: How to know the size of a directory? If I run ls -lh then any given directory is just shown as 4.0K. How can I can make it consider the files the directory refers to ...
1
vote
0answers
142 views

How can I list only the directories present in a directory using ls? [duplicate]

Possible Duplicate: Is there any option with 'ls' command that I see only the directories? I have a directory with a lot of files but only a few directories. To get a list of only ...
2
votes
1answer
1k views

LS_COLORS settings for specific types of files

I'm trying to set up my color scheme for ls, and I'm having trouble finding information about exactly what parameters I have to work with, or where those come from. And especially setting colors for ...
4
votes
2answers
2k views

ls'ing through an entire directory tree to produce one pipeable list of files

This might have been answered already. But I wasn't able to find it. I have: directory directory/subdirectory/subdirectoryofsubdirectory ...
6
votes
1answer
6k views

+ or @ mark after running 'ls -al'

In Mac OS X, run 'ls -al' gives me something like this. drwxrwxrwx+ 4 smcho staff 136 May 5 09:18 Public drwxr-xr-x+ 6 smcho staff 204 Feb 1 2010 Sites drwxrwxrwx 9 smcho staff ...
27
votes
5answers
8k views

Is there any option with 'ls' command that I see only the directories?

Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that? EDIT: I'm using Mac OS X, and ls -d gives me . even though ...
6
votes
1answer
631 views

How do I get a long listing for a single directory?

I want to see a long listing for a single directory. When I type ls -lha, I see this: drwxrwxr-x 4 username groupname 4.0K 2010-08-05 09:55 files drwxrwxr-x 7 username groupname 4.0K 2010-08-05 ...
30
votes
3answers
3k views

What does size of a directory mean in output of 'ls -l' command?

What does size of a directory mean in output of ls -l command?
28
votes
6answers
6k views

what does the @ mean in ls -l?

I am using Mac OSX. When I type ls -l I see something like 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 ...