The ls command lists the contents of a directory.
23
votes
5answers
2k 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
1answer
222 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 ...
12
votes
5answers
4k 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 ...
3
votes
2answers
274 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 ...
8
votes
4answers
12k views
How to list files without directories, and filter by name (ls options)
I have a directory called uploads. It contains a bunch of files, plus a few subdirectories which in turn contain files.
Is there a way I can (in one step) do the following:
List ONLY the files in ...
1
vote
4answers
2k views
ls list files not matching given string in filename
I have a directory in which lot's of files (around 200) with name temp_log.$$ are created with several other important files which I need to check.
How could I easily list out all the files and ...
2
votes
2answers
484 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 ...
1
vote
2answers
239 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 ...
3
votes
1answer
560 views
copying device nodes
I'm trying to transfer a working Linux installation to a new larger disk, so I've attached the new disk on a USB port, partitioned it and created filesystems.
While copying all the files over I hit a ...
3
votes
3answers
370 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
5answers
1k 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
1answer
97 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 ...
4
votes
1answer
216 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 ...
5
votes
4answers
690 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 ...
0
votes
1answer
419 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 ...
5
votes
4answers
345 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+ ...
1
vote
1answer
290 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 ...
11
votes
2answers
565 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
2k 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 . ...
2
votes
6answers
2k views
Show only hidden files (dot files) in ls alias
I'm using the command
ls -a | grep '^\.'
for showing only the hidden files.
I added the line
alias hidden='ls -a | grep '^\.'' # show only hidden files
to .bash_aliases file
but this does not ...
4
votes
3answers
282 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 ...
4
votes
4answers
3k views
last time file opened
Is it possible to get the time when file was opened last time and sort all files in a directory by those times?
2
votes
2answers
637 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 ...
8
votes
6answers
2k 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 ...
1
vote
1answer
262 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.
5
votes
2answers
720 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
205 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 ...
2
votes
2answers
377 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
783 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 ...
2
votes
2answers
112 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
323 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
187 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 ...
8
votes
6answers
2k views
What does the “number” in the owner field of files signify in linux?
I copied many files to my new linux host. I see that all files have the owner and group both set to 515. What does that mean?
4
votes
5answers
811 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 ...
2
votes
2answers
1k 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 ...
2
votes
4answers
3k 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
1k 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
436 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
3answers
438 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 ...
2
votes
1answer
377 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?
9
votes
2answers
1k 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 ...
3
votes
2answers
674 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 ...
5
votes
4answers
2k views
How do I limit the number of files printed by ls?
Is there a way to limit the quantity of listed files on a ls command?
I've seen:
ls | head -4
but to get head to be executed I need to wait for ls to finish execution,
and with directories with an ...
0
votes
2answers
310 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 ...
2
votes
3answers
3k 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 ...
5
votes
4answers
9k 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?
3
votes
2answers
134 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
479 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
5
votes
5answers
5k 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
8
votes
2answers
377 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 ...
