The ls command lists the contents of a directory.

learn more… | top users | synonyms

5
votes
1answer
475 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 ...
6
votes
4answers
2k views

How to get the relative paths with ls?

I'd like to do something like this to move the last two downloaded files: mv ` ls -rt ~/Downloads/ | tail -2 ` . Unfortunately, ls only gives the filenames. How can I adapt the code above? (Before ...
10
votes
2answers
573 views

Highlight the three last updated files in ls output

Is there any way to overload or wrap the ls command so that it will highlight / underline / otherwise make obvious the last three modified files? I know that I can simply ls -rtl to order by reverse ...
0
votes
1answer
871 views

Asking ls to only list files in a path that match a specific glob/regex

In Zsh: Is there a way to use ls to only list files and folders in the current directory that match a specific globbing or regex pattern? For example, say I have multiple files that start with the ...
16
votes
6answers
15k views

How to match case insensitive patterns with ls?

I would like to list all files matching a certain pattern while ignoring the case. For example, I run the following commands: ls *abc* I need to see all the file that have "abc" as a part of the ...
1
vote
1answer
472 views

M-x ansi-term colors in Emacs 24.x

I have noticed that some colors in LS_COLORS don't work when running a shell inside M-x-ansi-term in Emacs. For exmaple; di 00 94 is supposed to turn on bold on light blue on directories on ...
6
votes
4answers
724 views

ls colors for permissions

Is there a way to control the color output of ls to highlight specific permissions on files? (e.g. write permissions). Any options in LS_COLORS that would do this? (the image above is from Dired+ ...
7
votes
7answers
17k views

List only regular files (but not directories) in current directory

I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find find . ...
4
votes
3answers
1k views

How can I do the equivalent of tail -f with ls? [duplicate]

Possible Duplicate: Is it possible to follow a command (run repeatedly)? as one would follow a file using tail -f? I would like to monitor files that are being downloaded to a directory in ...
2
votes
2answers
2k views

Setting up LS colors with a human-readable script in tcsh

I have a shell script (set_up_my_ls_colors.sh) that, if I call from my shell, it configures my color scheme for ls. The nice thing about the script is that it allows me to configure colors in a ...
11
votes
6answers
9k 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 ...
3
votes
2answers
996 views

List all chflags file flags?

Is there a way to see a file's flags, such as hidden, schg, etc? I've got an rwxrwxrwx file that I can't edit, and I think a flag might be responsible.
8
votes
2answers
2k views

Output ls -l size field with digits grouped by thousands?

It is possible to make ls -l output the size field with digits grouped by thousands? If so, how? For instance: $ ls -l -rw-rw---- 1 dahl dahl 43,210,052 2012-01-01 21:52 test.py (Note the commas ...
1
vote
3answers
731 views

Display a menu of files names and let the user select a file by entering a number

I have created a script that allows the user to select a file by copying and pasting that file. Then perform a grep on that file. I want to know is it possible to put a number in front of each files ...
3
votes
2answers
967 views

How can I stop ls from descending into directories, similar to prune for find?

If I type ls *ro* I also get files in subdirectories that match the *ro* pattern. Is there any option for ls similar to prune? Ideally a flag, otherwise perhaps an exec?
3
votes
2answers
1k views

How to solve sudo: unable to execute /bin/ls: Argument list too long

When I run this command from php sudo -u db2inst1 ls -t /var/lib/edumate/bdrs/*/*/daily/*NODE* | sort -r I receive sudo: unable to execute /bin/ls: Argument list too long ls lists all daily backup ...
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 ...
2
votes
2answers
141 views

What does it mean when the output of $ls -lasrt includes '.' and '..'

I input the command: $ ls -lasrt And the output includes (there are more results, these are the ones that confuse me): 4 drwxr-xr-x 5 tuc40953 stdchem 4096 Jul 3 17:48 .. 4 drwxr-xr-x ...
6
votes
3answers
479 views

Bash autocomplete gives different file name than ls

An incredibly strange thing just happened. Through a serious typo, I entered cp filename.xsl .^?~ Yeah, that's right, dot-caret-questionmark-tilde! Truth is stranger than fiction. It gets weirder. ...
1
vote
1answer
356 views

wdfs mount problem

I'm running Fedora/Gnome 3.4.2 64bit and I'm trying to mount a webdav file system to work with. As root, I run the command #mkdir /mnt/webdav #wdfs https://www.webiste.com:port/directory ...
5
votes
6answers
2k views

Strange case: Text file that exist and doesn't exist

I'm completely puzzled about a problem with a single plain text file in my system fedora 12. I used a known software in bioinformatics, maker, to produce lots of plain text files and one of them it ...
9
votes
4answers
4k views

How do I make ls sort underscore characters first?

I like being able to name files and directories with an underscore prefix if it's something I want to keep separate from other files and directories at the same level. On Windows and Mac, for example, ...
5
votes
4answers
13k views

Argument list too long for ls

I get the following error when trying to ls *.txt | wc -l a directory that contains many files: -bash: /bin/ls: Argument list too long Does the threshold of this "Argument list" dependent on distro ...
2
votes
1answer
5k views

How to get exact file size and file name?

Right now I am using ls -lt /my/directory (see below) then php parses the output. But inconsistently because the delimiter is space and there might be two or more spaces in between two fields. The ...
1
vote
1answer
959 views

What does @ sign mean in 'ls' output on Mac OSX Lion terminal? [duplicate]

Possible Duplicate: what does the @ mean in ls -l? What does the @ sign mean in the following "ls" output? -rw-r--r--@ 1 root wheel 489 Jan 4 13:14 boot.plist
2
votes
1answer
613 views

ls in glorious 256 colours [closed]

Apart from the ls colors solarized theme, is there any other ls colour themes out there that you would recommend for a dark background with a urxvt terminal?
2
votes
3answers
595 views

Can I list only specific subdirectories?

I have a folder tree structure like arndell \_databases \_daily \_weekly claremont \_databases \_daily \_weekly monte \_databases \_daily \_weekly and I am only after all files inside ...
12
votes
2answers
3k views

Why does ls sorting ignore non-alphanumeric characters?

When sorting file names, ls ignores characters like -,_. I expected it to use those characters in sorting as well. An example: touch a1 a2 a-1 a-2 a_1 a_2 a.1 a.2 a,1 a,2 Now display these files ...
12
votes
1answer
6k views

ls taking long time in small directory

Running Ubuntu, I open a terminal and do sudo bash cd / ls | head -n 1000 And predictably about 20 directories are returned. However, if I do an ls, and don't pipe it into anything, the ls just ...
3
votes
2answers
6k 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 ...
15
votes
7answers
9k views

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort ...
11
votes
2answers
1k views

“ls -lh” reports total size less than sum of individual sizes

Under what circumstances would ls -lh show a total that is less than the sum of the individual files? For example: $ ls -lh /var/lib/nova/instances/_base total 100G -rw-rw-r-- 1 nova nova ...
1
vote
3answers
781 views

dircolors “missing second token”

I'd like to customize the colors of ls and as far as I understand the way to go is with dircolors. I did: dircolors > ~/.dircolors Immediately after this I launch a terminal and get this error: ...
0
votes
2answers
506 views

ls outputs multiple columns even if piped to grep with grml's zsh config

I just decided to give zsh a go against Bash and came across some unhandy behaviour about which I couldn't find anything on the net: If you do a ls | grep foo in Bash, the ls only contains one file ...
7
votes
4answers
25k 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
3answers
8k views

ls to show only directory/filename and size

First of all, this is not a duplicate of this: Linux ls to show only filename date and size Because I want to print actual directory name additionally. I was always using this command: ls -l | awk ...
3
votes
2answers
311 views

Is it possible to show the contents of a directory without changing into it?

I'd like to show the contents of a folder without first changing into it. for example: ---- Documents | | L_ Essays If I'm in Documents, how can I show the contents of ...
7
votes
1answer
870 views

Why isn't the ls command listing huge filesizes?

In my Redhat Linux, I am getting the following error when executing the ls command. # ls ls: sugar.sql: Value too large for defined data type
8
votes
2answers
755 views

What is the point of ls -f (or, why is this hanging?)

I've got a directory with about 100,000 files in it. ls -f hangs for over a minute. I ran strace, and immediately started seeing getdents, so ls is clearly reading the directory. I also see a lot ...
5
votes
1answer
5k views

How can I use `find` and sort the results by mtime?

I want to use find but sort the results reverse chronologically as with ls -ltr. Is this possible through any combo of flags or pipelines?
3
votes
2answers
6k views

Want to sort files by update date including sub-directories

I want to sort only files by update dates including sub-directories. I found out ls -lrtR | grep ^-. but it doesn't seem to sort by update dates. And I need to save this list into a file. Is it ...
3
votes
3answers
3k views

How to search and replace text in all php-files in a directory and it's subdirectories

I am looking for a shell script that recursively traverses all .php files in a directory and performs a search & replace of a particular text pattern. The search pattern is quite long ( > 5000 ...
3
votes
2answers
3k views

file block size - difference between stat and ls

I've noticed that when I do a: ls -ls file It provides block count, say 8 blocks. When I do: stat file I notice that the block count is 16, twice the number given by ls. The block size on my ...
8
votes
3answers
3k views

How can I use ms-dos style wildcards with ls and mv?

I have the misfortune of coming from a MS-DOS background - but at least it makes me appreciate how much more powerful Linux is. I've been working on getting my Linux-Fu up to par, but there are a ...
2
votes
2answers
2k views

How to change the colour of embedded terminal in linux mint 12 to be able to use `ls` and `byobu`?

I'm using Linux Mint 12 and am having problems with the embedded terminal in gedit. Using the default themes I'm unable to use 'ls' and 'byobu' as in part of their output foreground and background ...
5
votes
2answers
2k views

What's the difference between “s” and “S” in ls -la?

When I ls -la, it prints many attributes. Something like this: -rwSrwSr-- 1 www-data www-data 45 2012-01-04 05:17 README Shamefully, I have to confess I don't know the exact meaning of each ...
3
votes
2answers
149 views

How do I create a structured list of all the files and directories under a particular directory (recursively)?

I need to have an "image" of a file system without actual contents of the files - just all the names and the structure, so that I can read the file and know what files were stored there and how were ...
7
votes
6answers
7k views

What's the best way to count the number of files in a directory? [duplicate]

If parsing the output of ls is dangerous because it can break on some funky characters (spaces, \n, ... ), what's the best way to know the number of files in a directory? I usualy rely on find to ...
-2
votes
1answer
267 views

Why does this script show all files in the directory and not just PDF files?

I wrote the script below to find the number of PDF files in a given directory. However, it instead shows all the files in the directory: #!bin/bash message="." message1="*.pdf" ls -al $message ...
3
votes
1answer
353 views

Zsh autocomplete ls command with directories only

Suppose I have following files and directories: % ls bui00293 buiawer builds/ buiowpe/ I want to list the content of ...