Questions tagged [ls]

A utility in Unix-like systems such as Linux used for listing files and directories.

A utility in Unix and Unix-like operating systems used for listing files and directories. It is analogous to the dir command used in DOS and Windows.

Documentation

1314 questions
51
votes
2 answers

Regular Expression usage with ls

I am trying to use ER (Extended Regular Expressions) with ls like ls .+\..+. I am trying to print all files which contains an extension (I know I could have used ls *.*, but I wanted to try using ER). When I run that code I get this error: ls:…
Lucas Rezende
  • 2,516
  • 8
  • 25
  • 34
47
votes
11 answers

Delete all files except the newest 3 in bash script

Question: How do you delete all files in a directory except the newest 3? Finding the newest 3 files is simple: ls -t | head -3 But I need to find all files except the newest 3 files. How do I do that, and how do I delete these files in the same…
bytecode77
  • 14,163
  • 30
  • 110
  • 141
44
votes
3 answers

Is there any way to find out changed file after some date in whole project code?

see i am working in one BIG project source code Now i want to know which files are modified after some date. Is there any command or any way to get that.. i have tried # ls -R -l but here it shows all file with last modified data but i want to…
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
44
votes
5 answers

Using ls, how to list files without printing the extension (the part after the dot)?

Suppose I have a directory with some files: $ ls a.c b.c e.c k.cpp s.java How can I display the result without the file extension(the part following the dot, including that dot)? Like this: $ a b e k s
Yishu Fang
  • 9,448
  • 21
  • 65
  • 102
43
votes
3 answers

what does terminal command: ls -l show?

I know that it outputs the "long" version but what do each of the sections mean? On my mac, when I type in ls -l /Users I get total 0 drwxr-xr-x+ 33 MaxHarris staff 1122 Jul 1 14:06 MaxHarris drwxrwxrwt 8 root wheel 272 May 20…
mharris7190
  • 1,334
  • 3
  • 20
  • 36
41
votes
7 answers

Find count of files matching a pattern in a directory in linux

I am new to linux. I have a directory in linux with approx 250,000 files I need to find count of number of files matching a pattern. I tried using following command : ls -1 20061101-20131101_kh5x7tte9n_2010_* | wc -l I got the following error…
db1
  • 2,939
  • 3
  • 15
  • 13
40
votes
10 answers

Maximum number of inodes in a directory?

Is there a maximum number of inodes in a single directory? I have a directory of over 2 million files and can't get the ls command to work against that directory. So now I'm wondering if I've exceeded a limit on inodes in Linux. Is there a limit…
Mark Witczak
  • 1,563
  • 2
  • 14
  • 13
40
votes
2 answers

How to filter the output of ls command to display only files created in February?

For Linux OS, How to filter the output of ls command in terminal to display only files created in February?
Amr Ragaey
  • 1,043
  • 1
  • 10
  • 16
38
votes
6 answers

Finding executable files using ls and grep

I have to write a script that finds all executable files in a directory. So I tried several ways to implement it and they actually work. But I wonder if there is a nicer way to do so. So this was my first approach: ls -Fla | grep \*$ This works…
k13n
  • 787
  • 1
  • 8
  • 8
38
votes
5 answers

How do you determine what bash ls colours mean?

When you perform ls in a bash shell, sometimes there are colours to indicate different resource types, and you can enable/control this with the --color argument. But neither the man page nor Google is providing an answer to the question: What do…
Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
38
votes
5 answers

How to `ls` only one level deep?

I have lots subdirectories containing data, and I want a short list of which jobs (subdirectories) I have. I'm not happy with the following command. $ ls H2* H2a: energy.dat overlap.dat norm.dat zdip.dat ... (much more) H2b: energy.dat…
Nick Vence
  • 754
  • 1
  • 9
  • 19
37
votes
4 answers

How do I capture the output from the ls or find command to store all file names in an array?

Need to process files in current directory one at a time. I am looking for a way to take the output of ls or find and store the resulting value as elements of an array. This way I can manipulate the array elements as needed.
fzkl
  • 977
  • 3
  • 11
  • 17
35
votes
4 answers

What does the dot at the end of the permissions in the output of "ls -lah" mean?

I found some Linux files, and when I type ls -lah, it outputs this permissions format: ... drwxr-xr-x. 2 root root ... -rw-rw-r--. 1 root root ... I would like to know, what is the meaning of the dot (-rw-rw-r--.) at the end of the…
miller
  • 1,636
  • 3
  • 26
  • 55
35
votes
7 answers

how to `git ls-files` for just one directory level.

I'm using msysgit (1.7.9), and I'm looking for the right invocation of the git ls-files command to show just the (tracked) files and directories at the current level, either from the index, or the current working directory if that's easier.…
Philip Oakley
  • 13,333
  • 9
  • 48
  • 71
31
votes
2 answers

Preserve ls colouring after grep'ing

If I do $ ls -l --color=always I get a list of files inside the directory with some nice colouring for different file types etc.. Now, I want to be able to pipe the coloured output of ls through grep to filter out some files I don't need. The key…
duckyflip
  • 16,189
  • 5
  • 33
  • 36
1 2
3
87 88