The ls command lists the contents of a directory.

learn more… | top users | synonyms

3
votes
2answers
1k views

Why does a new directory have a hard link count of 2 before anything is added to it?

Say I just create directory newDirectory and then I do ls -ld command. I see that the number of hard links is 2. What exactly makes the hard link 2 from the start? Also is the number of subdirectories ...
0
votes
1answer
86 views

How can number of subdirectories and files be determined from ls -ld command? [closed]

How can number of subdirectories and files be determined from the output of using ls -ld command? I realize that this command only lists the directories.
0
votes
2answers
90 views

How can I for example list five largest files in /usr/lib -directory?

How can I for example list five largest files in /usr/lib directory? Please also add some minor explanation for each bit of code that you are using.
1
vote
2answers
259 views

In a Bash if condition, how to check whether any files matching a simple wildcard expression exist?

Stupidly, I had been using a condition like this as part of a script: if [ $(ls FOO* 2> /dev/null) ] # if files named "FOO*" were downloaded then echo "Files found" # ... process and ...
0
votes
2answers
448 views

Using `ls` recursively without -R

I am trying write a shell script that has output similar to ls -R without using the option -R. This is part of a programming assignment that forbids me from using -R, find and du. I need to identify ...
0
votes
1answer
235 views

How to hide file size using ls command

I need to list some files in a directory using the ls command, but I need to also to hide the file sizes. How can I do that with the ls command?
1
vote
2answers
120 views

How to use `ls` to group and show only a first word of directory name?

I want to define a new ls command to do something like this The first when i use ordinary ls command: $ls undergrade.AI undergrade.KDD undergrade.AI2 undergrade.micro ...
4
votes
3answers
438 views

How to inspect group permissions of a file

I would like to inspect group permissions of a file from a bash script. Specifically, I need to check whether a file has the group writeable bit on. That's it. Simple as that. However: I also need ...
3
votes
3answers
126 views

How can I list all files and symlinks in a compact view?

This is my setup in /tmp/test/ if I use ls -l -rw-r--r-- 1 rubo77 rubo77 0 Okt 21 04:15 a -rw-r--r-- 1 rubo77 rubo77 2 Okt 21 04:16 b drwxr-xr-x 2 rubo77 rubo77 4,0K Okt 21 03:58 c ...
1
vote
1answer
88 views

What does * next to the file name mean in the output of ls? [duplicate]

I have a doubt related the output of ll command. When, in my shell, I execute the ll command I obtain this output: -rwxrwxr-x 1 andrea andrea 104215 ott 15 15:56 atmosfs* Why I have the * next to ...
0
votes
2answers
382 views

zsh alias being overridden somehow

I'm on a system running OS X 10.8.5. I recently tried to alias ls to ls -G -la command. I opened up ~/.zshrc, put in the alias, relaunched the terminal, but the change didn't take effect. Upon ...
-2
votes
3answers
212 views

make ls display current date and time

I'm new to Linux and I'd like ls to display current date and time as a side effect every time I use ls. How do I go about changing what a command does?
3
votes
2answers
84 views

dircolors: rules for _ext (rather than .ext)

In UNIX, many file extensions do not contain the dot in front, as in bashrc rather than bash.rc or ssh_config rather than ssh.config I would like to add dircolor rules for _config as well. However, ...
7
votes
2answers
5k views

What causes this green background in ls output?

There are two directories shown by 'ls'. Normally directories anywhere are blue on black background. But the first one is blue on green and impossible to read. Why is this? How to make it blue ...
9
votes
3answers
5k views

dircolors: modify color settings globaly

I understand ls uses dircolors to display colored output. dircolors has default database of colors associated with file extensions, which can be printed wiht the command dircolors --print-database ...
6
votes
3answers
114 views

Excluding . and .. from results in find and ls

Is there any way to prevent find and ls -l from listing . and .. in their results? I never care about seeing this result in the output, and it prevents me from effectively piping their output to wc -l ...
4
votes
2answers
4k views

List subdirectories only n level deep

Festival stores voicepack data in the following example directory structure: /usr/share/festival/voices/<language>/<voicepack name> What is the simplest one-liner (preferably using ls) ...
4
votes
2answers
364 views

'ls -l' file timestamp format

When I issue the command: ls -l The file/directory modification timestamp column (specifically the month part) is displayed in the native language of the country I'm based in instead of English. ...
1
vote
2answers
84 views

How to let `ls` display the results order in row first?

I type ls in my terminal, A0001 A0004 A0007 A0010 A0015 A0018 A0021 A0024 A0028 A0031 A0034 A0037 A0040 A0043 A0046 A0049 A0052 A0055 A0058 A0061 A0064 A0067 A0002 A0005 A0008 ...
4
votes
3answers
156 views

ls on device without mounting it

Is it possible to run ls on a device without mounting it first? Something like this: # ls /dev/sda1
3
votes
5answers
697 views

How can I concatenate a single column of output into a list?

I'm using: ls /proc | grep -v "^[0-9].*" to get a list of all the files and directories in /proc that don't begin with numbers. The output is a single column list, i.e.: acpi asound buddyinfo bus ...
23
votes
12answers
3k views

What's the most resource efficient way to count how many files are in a directory?

CentOS 5.9 I came across an issue the other day where a directory had a lot of files. To count it, I ran ls -l /foo/foo2/ | wc -l Turns out that there were over 1 million files in a single ...
2
votes
1answer
184 views

What file type categories do colors in the terminal represent in various distros (by default)?

I'm discovering new file type categories (if one can call different colors in the terminal in such a manner) almost on a daily basis. Still, I haven't found an exhaustive list of all recognized file ...
2
votes
3answers
380 views

Command substitution in for loop not working

I want to keep all files not ending with .bat I tried for f in $(ls | egrep -v .bat); do echo $f; done and for f in $(eval ls | egrep -v .bat); do echo $f; done But both approaches yield the ...
7
votes
3answers
4k views

Sorting files according to size recursively

how to scan a folder recursively and find the largest files in the folder, and sort them by size. I have tried using ls -R -S but it tends to list the directories as well I need to scan the folders ...
1
vote
2answers
4k views

How to sort results from ls command by modification date (directories first)?

I can fire ls -lrt to get files and folders sorted by modification date, but this does not separate directories from files. I want ls to show me first directories by modification date and then ...
2
votes
3answers
684 views

How can a group own a file?

Whe I do ls -l, two of the fields are username of the owner and name of the owning group. The username is clear - I created the file, it is mine. However the group entry confuses me. My user is a ...
3
votes
2answers
382 views

How to set what field names are displayed in listings?

When I execute a command in Ubuntu, which results in a listing, I get results without the field names. Example is ls -l or ps l. I am not very experienced and always need to go digging through man ...
2
votes
5answers
175 views

List a directory but only if it contains sub-directories?

In Unix, is it possible to use one command ONLY to list directories if they contain a sub-directory? For example, I would like to list the directory name if it contains a sub-directory called ...
3
votes
1answer
187 views

How to disable flashing file names in rlogin

I have a strange problem with my rhel 6.4 system. If I do a rlogin to any of my machines, all the files in the remore machine will be flashing and it is so annoying. Can somebody please tell me how ...
3
votes
1answer
1k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
1
vote
4answers
398 views

Tail -f the most recent log file

In a few spots I got this to work ls -rt /path/to/log/file/ | tail -1 | xargs tail -f But I can't figure out why it won't always work (This is quick fix until I get the log rolling fixed here)
1
vote
1answer
194 views

The result of echo * and echo .*

Thereotically, the result of command echo * should be "Any file in the current directory". Should it include the dotfile? Similarly, Should the result of ls * include the dotfile?
1
vote
2answers
1k views

Cheapest way to find the oldest file (recursively) from a directory under heavy load

What is the least expensive way to find the oldest file in a directory, including all directories underneath. Assume directory is backed by SAN and under heavy load. There is concern that "ls" could ...
2
votes
2answers
212 views

ls should display contents of flat directory structure in columns

I've got the a flat directory structure like this. ├── kanban │   ├── 1_backlog │   ├── 2_analyze │   ├── 3_doing │   ├── 4_test │   ├── 5_approval │   └── 6_done Each directory contains text ...
1
vote
2answers
248 views

MacOsx - Shell - list all .php files and their octal permissions, inside a specifc folder

is it possible to list all the ".php" files located into a direcotry and their octal permissions? I would like to list them like this: 775 /folder/file.php 644 /folder/asd/file2.php etc...
1
vote
1answer
350 views

How to “mute” ls command?

Suppose I do a recursive ls $ ls -R on the root directory. I get a lot of messages like these - ls: cannot open directory ./var/lib/sendmail: Permission denied ls: cannot open directory ...
7
votes
4answers
2k views

View permission / owner of full directory tree

I remember doing someting like "XXX /home/user/dir/child/file" and it returned the owner and/or permission of: /home /home/user /home/user/dir /home/user/child /home/user/child/file But I don't ...
5
votes
1answer
781 views

What do the symbols displayed by ls -F mean?

I noticed that if I run ls -F on a directory, some of the entries have a * or a @ after them. spuder@ubuntu:~$ ls -F /sbin acpi_available* getpcaps* lvmconf* ntfscp* ...
4
votes
3answers
3k views

What does ll alias to?

ll is a common alias in many linux distros. How can you tell what it aliases to? I've tried checking my .bashrc, but I am not able tell what ll is equivalent to.
0
votes
4answers
873 views

List only files in a directory and show the inode number

How can I list all files but not directories in a given directory and show the inode-numbers. Something like ls -li | grep ^- does not work since the inode number is shown in the beginning of the ...
1
vote
3answers
2k views

What does `l` mean in an `ls` listing?

When I run ls -adl .* in one of my directories, I get a file that has this listing: lrwxrwxrwx 1 user group 43 Jul 3 16:25 .#filename.py -> person@computer.edu.4018:1372874769 The filename ...
0
votes
2answers
143 views

meaning of capital S in long ls output [duplicate]

What does this long listing mean? $> ls -l developer.haml -rw-rwSr-- 1 humon apache ...... I know what a usual listing means and I know all about what it means to be read 'r', write 'w', and ...
0
votes
3answers
144 views

How to delete directory ' :q!'? [duplicate]

Accidentally, i have got this directory created in my home, drwxr-xr-x 2 ubuntu ubuntu 4.0K 2012-09-06 07:27 :q!/ I want to remove this somehow. I have tried using escape characters in double ...
0
votes
1answer
90 views

Moving folders used wrong syntax and lost them

I thought I was being smart trying to move a folder to one level up by going: mv folder .newfolder and neglecting to even put: mv folder .newfolder/folder and anyway it didn't put up an error but ...
2
votes
2answers
191 views

Directories are listed twice

I have something odd. I creates some directories using a very simple script : ... create all directories ( running under a user that has the correct rights ) e.g : mkdir -p ...
0
votes
1answer
108 views

wc - setting a terminating character

I've got that far: wc --files0-from=FILE lets one get the word count of a list of files. Each entry in this list mus be terminated with an ASCII NUL character. Question: A way to set a terminating ...
3
votes
2answers
2k views

syntax of ls --hide= and ls --ignore=

ls --hide and ls --ignore provides the possibility leave out files defined through regular expressions set after the --ignore= part. The latter makes sure that this option isn't turned off via -a, -A. ...
1
vote
3answers
2k views

ls command - define number of columns

Is there a way to define the number of columns in ls output? I got this far: ls -C sorts in columns and ls -1 produces one column. --tabsize = option to produce two columns resulted in what looks ...
5
votes
2answers
527 views

Find/ls caching

It seems as though the first time I run find or ls on a directory, it takes a while to work. But, each time thereafter, it is fast, as though a list of the directory's contents has been cached or ...