The ls command lists the contents of a directory.

learn more… | top users | synonyms

-1
votes
3answers
292 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?
6
votes
3answers
129 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 ...
1
vote
6answers
5k 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 ...
5
votes
2answers
8k 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) ...
30
votes
3answers
4k views
4
votes
2answers
468 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
94 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
205 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
965 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 ...
2
votes
1answer
240 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 ...
5
votes
3answers
427 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
3answers
505 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 ...
12
votes
6answers
10k views

How do I list every file in a directory except those with specified extensions?

Suppose that I have a folder containing .txt, .pdf, and other files. I would like to list the "other" files (i.e., files not having the extensions .txt or .pdf). Do you have any advice on how to do ...
4
votes
5answers
14k 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 ...
27
votes
5answers
8k views

Is there any option with 'ls' command that I see only the directories?

Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that? EDIT: I'm using Mac OS X, and ls -d gives me . even though ...
1
vote
2answers
8k 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 ...
11
votes
1answer
2k 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* ...
3
votes
2answers
545 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
3answers
975 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 ...
2
votes
5answers
211 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
258 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
2k 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 │   ├── ...
17
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 ...
1
vote
4answers
706 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
283 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?
30
votes
7answers
4k views

why does ls -d also list files, and where is it documented?

when specifying ls --directory a* it should list only directories starting with a* BUT it lists files AND directories starting with a Questions: where might I find some documentation on this, ...
1
vote
2answers
2k 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
268 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
294 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
596 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 ...
6
votes
3answers
7k 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.
1
vote
4answers
2k 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
4k 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 ...
2
votes
4answers
13k 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 ?
0
votes
3answers
165 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
100 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
249 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
133 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 ...
4
votes
2answers
3k 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
3k 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
740 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 ...
3
votes
1answer
395 views

ls gives me different sort orders during a cron job

I have a cron job that, among other things, does a recursive ls of a directory into a file. This gets compared to another file that I've created that, supposedly, contains an identical listing of the ...
5
votes
2answers
2k views

Excluding a specific directory using a recursive 'ls'

I've been using the following command to list the most recently updated files (recursively) within a specific directory and order by modification time: $ stat --printf="%y %n\n" $(ls -tr $(find * ...
5
votes
2answers
570 views

Sort files by modification time

I've seen many questions and answers here using a construction along the lines of list_dir=`ls -t /path/to/dir/` for i in $list_dir; do or ls -t | while read i; do Now, I know that you shouldn't ...
15
votes
1answer
2k views

Why are reboot, shutdown and poweroff symlinks to systemctl?

In Arch Linux, if I do ls -l in /sbin, I can see that reboot, shutdown and poweroff are all symlinks to /usr/bin/systemctl. But issuing reboot, shutdown and systemctl commands obviously does not all ...
6
votes
6answers
4k views

Compare files that are in directory 1 but not directory 2?

I'm having trouble with a bash script I want to make I know ls will list files that are in a directory but I want it to list directories that are in directory1 but NOT in directory2, and then list ...
2
votes
2answers
4k views

Linux listing files between two date without touch command

I need a command which will list the files between given date and time (YYYYMMDDHHMMSS - format) in to a text file. I don want to use touch command as its creating permission issue. I am new to this ...
3
votes
1answer
58 views

Why aren't CD image files listed when mounted in current directory?

When mounting a disk image in the current directory using : sudo mount -o loop -t iso9660 wall.iso ./ Listing files in current directory only returns wall.iso . To view the actual files on the disk ...
3
votes
1answer
2k views

ACL, ls, “permission denied” and a lot of questionmarks

I have two users, Alice and Bob. Bob should be allowed to list, ls, Alice's home directory. Alice also has a file in her home directory that Bob should also be allowed to read. I run these commands ...
13
votes
2answers
2k views

What is the number between file permission and owner in ls -l command output?

The output of ls -l command yields the following result: What is the number field between file permission and owner? i.e. what are those 1, 1, 1, and 2? I checked the --help but that doesn't ...