The ls command lists the contents of a directory.

learn more… | top users | synonyms

5
votes
1answer
1k views

`ls` command does not list latest directory contents

The Linux shell does not print up-to-date information when it comes to ls. For example I use my other processes (IDEs etc) to create some directories. However when I run an ls command I don't see ...
1
vote
1answer
614 views

Total vs listed directories [duplicate]

On a server when I type in ls -al I get a list of the directories -bash-3.2$ ls -al total 12 drwxr-xr-x 3 root root 0 Feb 13 2011 . drwxr-xr-x 4 root root 4096 May 11 2011 .. drwxr-xr-x 55 ...
3
votes
2answers
132 views

customise ls color for directories contain specified file/s

How can I colorize directories contain files with word INCORRECT inside? Example: I have 3 directories which contain log file. dir_a/log dir_b/log dir_c/log The file log in dir_c contain word ...
1
vote
2answers
603 views

Ignore all matches to negated extglob pattern in recursive ls

I would like to recursively list all files in a directory which match a given input pattern using ls. (Oh, and this is in Bash). The only way I can think of to do this using ls is to shopt -s extglob ...
4
votes
2answers
6k views

list all files newer than given timestamp and sort them

I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted. Using SUSE Linux Enterprise Server 11. The ...
3
votes
0answers
875 views

ls and vim color on SunOS 5.8/Solaris 8

I want to use ls and vim with color on Sunos 5.8 SunOS 5.8 Generic_117350-11 sun4u sparc SUNW,Sun-Blade-2500 I have installed ls (GNU coreutils) 6.9 and vim 7.2 In ~/.cshrc: setenv TERM sun-color ...
4
votes
2answers
536 views

Get the complement of the result of an ls command

Let's say I have a directory with multiple files, all of which are either binary files (files with no declared extensions) and source files (.c extension). I do this: $ ls and get: README.md ...
2
votes
1answer
1k views

How does wc -l `ls` give the actual number of lines?

Can anyone explain to me how does this command work. wc -l `ls` while this command gives the total number of java lines or txt lines.
11
votes
2answers
25k views

How do I make `ls` show file sizes in megabytes?

What commands do I need for Linux's ls to show the file size in MB?
4
votes
2answers
687 views

Number of lines outputted by ls

When ls is called, it outputs all the files/directories in the current directory, attempting to fit as many as possible on each line. Why is it that when passed to wc -l, it outputs the number of ...
2
votes
1answer
210 views

Local, regular file causes `stat` or `ls -l` to hang

I've seen a few different questions about ls hanging. It's usually because they use the -l switch, which causes a stat on the file, which in turn is a bad symlink or pointing to an NFS mount or some ...
37
votes
6answers
5k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
0
votes
1answer
1k views

How to display directory permission without listing permission for their contents [duplicate]

Possible Duplicate: How can I make ls show information about the directory specified only, not info about its sub-files or folder contents? I am new to UNIX and I want to display the ...
1
vote
1answer
577 views

Please explain the output of the ls -all command

This is one of the many similar lines from the output from ls -all lrwxrwxrwx 1 subhrcho dba 25 Dec 6 01:36 beam-server.jpr -> .ade_path/beam-server.jpr What does the above signify ? I am ...
4
votes
4answers
2k views

List all files / binaries in current PATH

Is there an "easy" way of running an "ls -la" style command for listing all files / executable binaries in the current PATH? (I intend to pipe the output into grep, for looking for commands with ...
3
votes
5answers
451 views

Print non-existent files from a pipe input

I have a directory of lots of .PDF and .JPG files. There should be a .JPG file for each .PDF with the same name. I'm trying to use a command to find .PDF files that doesn't have a .JPG file. My ...
4
votes
2answers
629 views

how to use grep for specific files?

for example I type ls -altr | grep "23 Dec" so it will show files for 23 Dec only and I want to use grep for them, like ls -altr | grep "23 Dec" | xargs grep -l "some_string" but this doesn't ...
5
votes
3answers
293 views

What's the best way to list size of / in Terminal?

I want to see how much total space / is taking, but I don't know how to do that. I can use ls -hal and add up the subtotals, or I can use fdisk to tell me the size of that partition, but is there a ...
12
votes
2answers
5k views

What does the 'd' mean in ls -al results and what is that slot called?

In Linux, what does the d mean in the first position of drwxr-xr-x? And what are all of the possible letters that could be there, and what do they mean? I'm trying to learn more about the Linux file ...
0
votes
1answer
444 views

difficalty to save traceroute output in shell variable?

I need to filter and store traceroute output in shell variable (array). But I am getting some unusual output. As I try to explain in following lines. My present directory is temp, having some ...
1
vote
5answers
2k views

Identify folder in bash

I was trying to learn how to identify only folders within a folder on the main level. example: main -folder 1 -folder 2 -folder 3 I started with this script: #!/bin/bash ...
3
votes
3answers
507 views

Different count for compressed file listing vs directory listing

I was taking a backup of a folder, where I used the following command : sudo tar -zcvf www.tar.gz /var/www/ It successfully compressed, just for verifying the number of files in the compressed ...
1
vote
1answer
518 views

Why ls -lrth and ls -ltch gives different results

I was trying to find the time of database backup. Normally i use ls -ltch But this time i used ls -lrth It gave me different result for One file and all date-stamps were same for both ...
4
votes
2answers
1k views

How do regular expressions differ from wildcards used to filter files

While we use * to denote zero or more previous characters in grep, we use *.c to find all C files when we use it with the ls command like ls *.c. Could someone tell how the use of * differs in these ...
2
votes
2answers
7k views

Solaris + display file time stamp [year][month][day]

I have Solaris 10 machine I need to verify time stamp of some file in my Solaris machine And to get the following format [year][month][day] Example of working command on Linux ls -l ...
3
votes
2answers
3k views

Displaying the last N modified files?

How can I list the 10 most recently modified files of a certain extension, not all files, or the files modified during the last 2 days for example?
1
vote
2answers
117 views

Are there any pitfalls to overriding ls?

Is there anything to watch out for if you wanted to override ls? Is there a more reliable way of getting pagination out of ls? For example: function ls() { command ls -hp $@ | more; }
7
votes
2answers
195 views

Different colour for the KiB range in `ls -l`

Is there any sane way to highlight the 4th, 5th, and 6th columns from the right of the file size in ls -l? My intention is to make it easy to read a file size be it in bytes, KiBs, or MiBs. I do know ...
4
votes
3answers
3k views

what is total in the output of ls command [duplicate]

Possible Duplicate: ls command: what does the first line mean? I have an empty directory.I am using following command to view the contents of that directory. ls -lart The output I get is ...
4
votes
4answers
359 views

List any file ending with .in and corresponding .out with shell script

I have a directory full of files ending with different extensions, how would I list/select only the files ending with .in and corresponding .out that share the same basename? e.g. file1.txt file1.in ...
6
votes
1answer
690 views

Why could the size of the “dot” file “.” exceed 4096?

Today I found an "empty" directory with a size of 4MB. It had no visible contents, so I tried ls -lah. This showed me some hidden files (not very large). Searching for the reason why the directory ...
5
votes
3answers
296 views

How to ls using the long format (-l) while still following directory symlinks?

I've noticed that ls -l doesn't only change the formatting of the output, but also how directory symlinks are handled: > ls /rmn biweekly.sh daily.sh logs ... > ls -l /rmn lrwxrwxrwx 1 root ...
2
votes
4answers
12k views

Unix Command to return all files that end with single digit and TXT extension

Which command returns all files that end with a single digit and have the TXT extension ?
1
vote
1answer
985 views

Very basic question, ls a different directory and save file

I seriously can't understand where I'm going wrong with his question. The first part is. List all the file and directory names in /etc which have 1 or more numbers in their name. Remember to use ...
2
votes
1answer
6k views

Alias for directory listing sorted by time modified in reverse order

When I need to find my recently used files, this command: ls -lt lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because wont fit in ...
3
votes
2answers
156 views

Make ls distinguish scripts from binaries in output

Is it possible to make ls distinguish executable scripts from actual compiled binaries? The permissions are most often the same (+x), and with ls -F you get an asterisk suffix (*) for both, so it's ...
4
votes
1answer
1k views

What's the second column of ls -l say? [duplicate]

Possible Duplicate: What is the number between file permission and owner in ls -l command output? I've been using Linux for years now and I'm embarrassed to say that until now I didn't ...
18
votes
5answers
22k views

How to list all files in the size order

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
5
votes
1answer
189 views

Alphabetizing names in `ls` alias with .files not intermingled

I am currently using the following ls alias: alias ls='ls -alhGkpsq --color=auto'. This results in following directory listing. [03:35] bryson@brys ~ :$ ls total 48K 4.0K drwx------ 4 bryson 4.0K ...
1
vote
1answer
1k views

cannot 'ls' /mnt directory

I have a CentOS-6 machine that I'm working on that is running a live database. It's having a problem with the /mnt directory. I cannot ls the directory for some reason. stat is working and shows ...
3
votes
2answers
737 views

Why is bash giving me (apparently) conflicting information about a file?

Background I am working on a RHEL 5 cluster. I want my Fortran program to read the file /home/bob/inputs/input_1 I asked Bob to give me permission to read all contents of inputs: [bob@server]$ ...
2
votes
4answers
780 views

No such file or directory error when using xargs

I have some files with .mkv extension and I want to calculate their total size using du -h. Some of the files are preceded by whitespace characters. ranveer@ranveer:~$ ls *.mkv ...
1
vote
1answer
479 views

How can I list LS_COLORS in colour?

I recall that eval "dircolors -b" used to display the colours that LS_COLORS was using, based on the file types or extensions. It was not simply the colour values that were displayed but the colours ...
4
votes
2answers
699 views

Tmux eclipsed colorized output of ls

I'm running Xubuntu 12.04, and when I use the Terminal I get colored filenames from ls. But inside tmux, everything ls prints is white. I know my tmux supports color, though, because I get color ...
4
votes
5answers
12k views

ls list files not matching given string in filename

I have a directory in which lots of files (around 200) with the name temp_log.$$ are created with several other important files which I need to check. How can I easily list out all the files and ...
1
vote
2answers
349 views

List info about files/directories with spaces

I am trying to use ls to get information about files and directories. My current command fails to properly get the name whenever a file/directory has a space. I am using this to list all ...
4
votes
3answers
2k views

Using OR patterns in shell wildcards

Contents of my dir are $ ls -lrt total 0 -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 night.txt -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 noon.txt -rw-r--r-- 1 user1 admin 38 Oct 8 12:31 day.txt I ...
1
vote
6answers
4k views

ls: Do not show directories that match same pattern in wildcard searches, only files

Supposing I have something like the following, a typical business PC situation: drwxr-xr-x 1 whatever whoever 3 Oct 3 16:40 invoices2009 drwxr-xr-x 1 whatever whoever 4 Oct 3 16:40 ...
10
votes
1answer
2k views

ls everything that is _not_ a symlink

Does ls have a way to show negated conditions like "all files which are not a symlink"? I use the latter a lot in a project directory but other negations would be useful as well. For now, my research ...
5
votes
1answer
473 views

Symbolic links with ls, mv: forcing the functions to utilize “logical” addresses (remembering the original path)

It seems that for many basic functions operating on symbolic links, the physical path is used by default. However, cd works fine. When moving into a symbolic link, cd remembers where I came from so it ...