The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
5answers
42 views

Making a *nicely* formatted list of number of files in directories - awk & sed probably

I have lots and lots of files in a series of directories, and would like a nicely formatted list of how many files are in each directory. The directories are ordered thus: Parent directories named ...
14
votes
11answers
47k views

Show sum of file sizes in directory listing

The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current ...
1
vote
0answers
11 views

LS_COLORS mixing matching criteria, e.g. file extension and hardlink

I'm wondering if there is a way to keep the characteristic color of the extension type in ls --color=auto and underline the file if is a hard link. For instance, if I do ...
3
votes
1answer
45 views

“Display all <num> possibilities? (y or n)” for ls command

When I attempt to tab complete a filename in the bash prompt, and the output would be many (>100) filenames, the shell asks Display all <num> possibilities? (y or n) Can I replicate this ...
12
votes
4answers
46k views

How can I list subdirectories recursively?

The obvious ls -dR does not work. I am currently using find /path/ -type d -ls but the output is not what I need (plain listing of sub-folders) Is there a way out?
2
votes
1answer
88 views

Why root bash output is colored but `sudo ls` output is not?

In bash (Ubuntu) I get colored outputs either as root (after sudo su) or as a normal user. I checked (after reading this post) the files .bashrc for normal user and superuser and the options related ...
0
votes
1answer
36 views

get List of files which are unique

I have a directory in which files are created as abc.sh.ID.datetimestamp.id.log In the filename abc.sh, ID are always same (there are 1000's .sh's and ID's combination in environment). datetimestamp ...
5
votes
1answer
38 views

Is it possible to make ls ignore Windows hidden files?

I'm using the GnuWin32 libraries on a Windows 7 machine. Everything is working fine except that the ls command is showing all of the NTFS hidden files. The solutions I've found for this so far all use ...
3
votes
3answers
2k views

ZSH: `ls *(.)` lists regular files only but `ls *(/)` does not list directories only

I'm not sure I am using ZSH's globbing correctly, but I thought ls *(/) would just list the dirctories under pwd, but it doesn't, it recursively lists all files under every directory under pwd (I got ...
12
votes
3answers
750 views

No colored output in less for the ls command

If I run ls I get colored output which I find pretty handy for quickly getting a glance of the kind of file. When I try to pipe it to less even with the -r and -R flags the coloring always get lost. I ...
0
votes
4answers
41 views

Single line command to cat last file in ls -lrt output? [duplicate]

System log files are serialized and I use ls -lrt to show me the most recent file. I then cat that file. This requires typing a long serial number each time. How can I cat the last file appearing in ...
4
votes
1answer
96 views

ls -l numbers between the size and the group

when I run ls -l /dev/null /dev/zero /dev/tty I get: crw-rw-rw- 1 root root 1, 3 Aug 9 09:05 /dev/null crw-rw-rw- 1 root tty 5, 0 Aug 9 09:05 /dev/tty crw-rw-rw- 1 root root 1, 5 Aug 9 09:05 ...
12
votes
7answers
14k views

How to report number of files in all subdirectories?

I need to inspect all sub-directories and report how many files (without further recursion) they contain: directoryName1 numberOfFiles directoryName2 numberOfFiles
0
votes
2answers
49 views

Get number of files in each directory [duplicate]

I have a directory with a very large number of subdirectories (~800) that were generated programmatically. I want to get a count of the number of files in each of these subdirectories to check for ...
11
votes
4answers
18k 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 ...
5
votes
4answers
2k 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 ...
0
votes
2answers
103 views

What is the alternative for ls command in linux? [duplicate]

How can I list the current directory or any directory path contents without using ls command? Can we do it using echo command?
13
votes
7answers
2k views

What to use when the “ls” command doesn't work?

I tried to use the ls command and got an error: bash: /bin/ls: cannot execute binary file What can I use instead of this command?
0
votes
0answers
21 views

To list only the file names in a present working directory using unix shell command [duplicate]

There are some links,directories and files in my path. I want to list only the file names eg. logfile1 redolog1 dumplog1 logfile2 lrwxrwxrwx spsy spec Jun 23 2343243 jpeg --> ~/home/s/jpegs ...
4
votes
4answers
296 views

Sorting directories by last modified date/time of the same-named contained file

Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example: domain1/file.php (last modified 20-Jan-2014 ...
1
vote
2answers
24 views

How can I list files by class/indicator (as in ls --classify) then by name?

ls --clasify append indicator (one of */=>@|) to entries. I would like to group the entries of the same class/indicator together. I can only find ls --group-directories-first for grouping the / ...
5
votes
3answers
14k views

List of Recently Modified Files

How can I Get a list of all files modified , say 3 months ago. I checked this question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there ...
2
votes
2answers
246 views

How to remove all but last 10 files

I accumulate sequentially named files as the result of an automated process, and I would like to keep only the last 10 around. I tried this, which had the effect of deleting everything: ls -r | more ...
0
votes
0answers
25 views

how to list only files on Unix using ls command? [duplicate]

for listing only directories in Unix i can use ls -ld */, how to list only files? problem - I have some of files and directories in a directory, i want list only files
0
votes
1answer
27 views

ls displays files copied from an external drive with a yellow background

I copied some files from an external drive and now they appear with a yellow background under my ZSH shell on OSX. I believe that its a permissions thing as the normal ones display "drwxr-xr-x" and ...
8
votes
6answers
603 views

How do I display the nth result of an ls command?

I used this command to display the first result of files in my directory. ls | head -n 1 My simple question is, how can I modify this command to display say the nth result? Thanks!
12
votes
5answers
12k views

How to turn off color with `ls`?

It is normally nice to have color output from ls, grep, etc. But when you don't want it (such as in a script where you're piping the results to another command) is there a switch that can turn it ...
2
votes
1answer
267 views

How to do ls with a wildcard and see the directory name

I have a directory called selenium_IDE if I do ls sel* I get to see directories that are in it, e.g. $ ls sel* HAPPY HAPPY_PLUS_OPTIONS SAD SAD_PLUS_OPTIONS but ...
3
votes
1answer
1k 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 ...
46
votes
6answers
12k 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 ...
1
vote
0answers
31 views

Who is this UID and GID? [duplicate]

When I do an ls -l on my ubuntu machine it shows the number 6226 as the UID and GID for some directories. Why? Most files and directories are owned by root, or by ubuntu (which is my usual login ...
0
votes
5answers
93 views

List only the count of all files/directories for the directory tree of present directory

I want to list the number of directories under each subdirectory tree of the present directory. As there are too many directories, I can't go into individual directory and check. Something like the ...
2
votes
1answer
2k views

Enable line breaks when assigning multi line outputs to var in bash

I'm using the following very basic shell script I copied off the net to list the contents of my database backup folder and mail them regularly: MYSQLLIST=$(ls -lhG /var/backups/mysql/daily/) ...
0
votes
2answers
53 views

How to find all .zip and .rar files recursively and sort them by size [duplicate]

I am looking for all .zip and .rar files in comp_tuts folder and I am intersted in showing their file sizes and sorting them from biggest to smallest. I have tried ls -R *.zip ls: cannot access ...
20
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 ...
0
votes
2answers
89 views

ls command lists hidden files

When I run ls command I get files like opencv.sh~ in my output which is not visible if I check the home directory. Basically, it also lists hidden files without supplying any other parameter. How can ...
7
votes
8answers
10k views

Convert ls -l output format to chmod format

Say I have the following output from ls -l: drwxr-xr-x 2 root root 4096 Apr 7 17:21 foo How can I automatically convert this to the format used by chmod? For example: $ echo drwxr-xr-x | ...
2
votes
1answer
49 views

Why is vdir still around?

After installing Debian 8, I started poking around /bin (as I'm always wont to do), and I noticed that ls and vdir share, not only the same manpage (except for the whatis line), but the exact same ...
29
votes
6answers
70k 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.
1
vote
1answer
52 views

Got weird result when executing bash command “cd /usr/share/; ls *z ”

I know the meaning of * wildcard But when I use Ubuntu 14.04 and type following command: $ cd /usr/share/ $ ls *z But why the part of the result is like this:    ...
3
votes
2answers
132 views

rm not deleting file, thinks its a directory

I have a hard drive with windows loaded on it hooked up to my Linux machine for backing up some of the information. I want to delete one of the 'temporary internet files' folders and it deleted all ...
3
votes
4answers
712 views

only show the source file and target linked file using `ls`

I can show the target file that a link points to using ls -l: snowch$ ls -l /usr/local/bin/mvn lrwxr-xr-x 1 snowch admin 29 12 Dec 08:58 /usr/local/bin/mvn -> ../Cellar/maven/3.2.3/bin/mvn Is ...
1
vote
1answer
69 views

Listing directories and understanding ls

On ls man page, I saw this -d, --directory list directory entries instead of contents, and do not dereference symbolic links on my current folder: drwxr-xr-x 2 oracle oinstall 4.0K Jul ...
1
vote
1answer
145 views

Display full ISO time in OSF1

I am working on an HP OSF1 (Tru64) based server and need to display file listings with the full-iso time format style. Example of this in Ubuntu Linux, user@hostname:~/Desktop$ ls -lrt --full-time ...
0
votes
2answers
47 views

Is there a way to list files before mount a disk partition

Suppose there are several partition in my computer. So I'm not sure where is the folder I have to access. usually what I do is mount all the portions first and then search one by one. Is there a way ...
0
votes
0answers
79 views

How to check if the shell script created a new error log file in a folder with the same shell script? [duplicate]

I am trying to check if the new file is created in the specific directory or not when I run the shell script. Here, I am creating a new file through the shell script itself and then checking whether ...
1
vote
5answers
145 views

list all files with extension .log except one

I would like to list all files with extension .log except the file backup.log. I have tried using this command: ls *.log -I "backup.log" But all the log files are listed, even backup.log! How ...
0
votes
2answers
34 views

Why is there a minor number in /dev for directories such as pts?

This is a part of /dev in CentOS 6.6. What is the meaning of the minor number for directories like ., .. , bsg, block and ... ? drwxr-xr-x. 18 root root 3800 Jul 3 06:00 . dr-xr-xr-x. 21 ...
0
votes
1answer
109 views

Meaning of chmod 1775

Created a folder "Sample_dir" and analysed its permissions. $ mkdir Sample_dir $ ll Sample_dir/ total 36 drwxrwxr-x 2 user user 4096 Jul 1 19:26 ./ drwx------ 71 user user 28672 Jul 1 19:26 ../ ...
1
vote
2answers
137 views

How to use logical OR in find?

In bash shell ls can use a logical OR functionality through (of course I could also do ls name1 name2 but my true examples are more complicated): ls @(name1|name2) Is there a way to do this using ...