Questions relating to the Linux 'list' command (ls)
Questions tagged [ls]
382 questions
112
votes
8 answers
How can I make ls only display files?
I figure there has to be a way of making ls only display non-directories, but the man page doesn't make it obvious
user453720
28
votes
8 answers
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 create a list of all the files in the current…

janet
- 589
24
votes
6 answers
What's the easiest way to remove the "total " 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, seems like it does, not sure what I was seeing…

Tom
- 526
20
votes
2 answers
How does ls -l format its output so neatly?
How does ls -l format its output so that column contents line up neatly?

DK Bose
- 42,548
- 23
- 127
- 221
15
votes
4 answers
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 to do so. To illustrate:
drwxr-xr-x 2 root root…
user25656
11
votes
3 answers
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 just displaying dump it shows me the ls of dump…

Ashfame
- 3,214
6
votes
1 answer
Preserving multi-column output from ls when paging
By default, ls displays its output in multiple columns, but when it's sent to a pager such as less it's reformatted as a single column. Is there any way I can page the original, multiple-column output and preserve the formatting?

Matty
- 2,384
3
votes
2 answers
"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 result which I expect:
ayakovlev@ubuntu:~$ ls…

HEKTO
- 555
- 1
- 8
- 24
3
votes
1 answer
Display all of the files where the extension starts with a certain letter using ls command
How do I display all files where its extension start with a certain letter using ls command?
I tried doing ls d* but that display all files starting with letter d, not extension starting with letter d.

Andy J.
- 31
- 1
2
votes
1 answer
List files that were changed between a certain datetime
Possible Duplicate:
How to remove files modified between particular dates?
How can I list all files recursively in a directory that were changed within a certain timespan?
like between 23.12.2011 and 25.12.2011 ?

clamp
- 1,699
2
votes
3 answers
How to remove all files with a pattern except the recently created file
How to remove all files with a pattern except the recently created file
ls -l
total 655748
-rw-r--r-- 1 jetty jetty 120579643 May 10 19:59 2023_05_10.jetty.log
-rw-r--r-- 1 jetty jetty 115205809 May 11 19:59 2023_05_11.jetty.log
-rw-r--r-- 1 jetty…

user352290
- 131
1
vote
0 answers
Set -h as default for ls?
I use the -h flag to make ls report in M,K,G etc
Can I set the -h flag to be the defaul for ls so I don't need to write it every time ?

SamH
- 111
1
vote
3 answers
ls command to view particular string in filename within directory
I have bunch of files in one directory. I want to list specific files within this directory whose name as follows;
stacov_abcd0230.15o
stacov_abcd0240.15o
stacov_ab120240.15o
stacov_01020240.15o
There are always 8 characters string after stacov_…

deepblue_86
- 1,194
1
vote
1 answer
What does `ls /` do?
Running the ls / command some files are coming out;
What are those files?
They are not even directories.
Output of ls /:
bin dev boot etc cdrom media mnt home lib lib64 proc root

Knight
- 13
1
vote
4 answers
Selecting from list like array (without name by number)
After I ls and see the list, is there anyway to process a document without typing its name?
For example instead of typing rm damnSoLongFileName, can I type something like rm [1]?
I mean is there anyway to use ls like array?

zahedae
- 23