The ls command lists the contents of a directory.

learn more… | top users | synonyms

9
votes
2answers
2k views

What does the 'd' mean in ls -al results and what is that slot called?

In Linux, what does the d mean in the first position of drwxr-xr-x? And what are all of the possible letters that could be there, and what do they mean? I'm trying to learn more about the Linux file ...
0
votes
1answer
264 views

difficalty to save traceroute output in shell variable?

I need to filter and store traceroute output in shell variable (array). But I am getting some unusual output. As I try to explain in following lines. My present directory is temp, having some ...
1
vote
5answers
1k views

Identify folder in bash

I was trying to learn how to identify only folders within a folder on the main level. example: main -folder 1 -folder 2 -folder 3 I started with this script: #!/bin/bash ...
3
votes
3answers
331 views

Different count for compressed file listing vs directory listing

I was taking a backup of a folder, where I used the following command : sudo tar -zcvf www.tar.gz /var/www/ It successfully compressed, just for verifying the number of files in the compressed ...
1
vote
1answer
379 views

Why ls -lrth and ls -ltch gives different results

I was trying to find the time of database backup. Normally i use ls -ltch But this time i used ls -lrth It gave me different result for One file and all date-stamps were same for both ...
4
votes
2answers
547 views

How do regular expressions differ from wildcards used to filter files

While we use * to denote zero or more previous characters in grep, we use *.c to find all C files when we use it with the ls command like ls *.c. Could someone tell how the use of * differs in these ...
1
vote
2answers
4k views

Solaris + display file time stamp [year][month][day]

I have Solaris 10 machine I need to verify time stamp of some file in my Solaris machine And to get the following format [year][month][day] Example of working command on Linux ls -l ...
1
vote
2answers
1k views

Displaying the last N modified files?

How can I list the 10 most recently modified files of a certain extension, not all files, or the files modified during the last 2 days for example?
1
vote
2answers
108 views

Are there any pitfalls to overriding ls?

Is there anything to watch out for if you wanted to override ls? Is there a more reliable way of getting pagination out of ls? For example: function ls() { command ls -hp $@ | more; }
7
votes
2answers
184 views

Different colour for the KiB range in `ls -l`

Is there any sane way to highlight the 4th, 5th, and 6th columns from the right of the file size in ls -l? My intention is to make it easy to read a file size be it in bytes, KiBs, or MiBs. I do know ...
4
votes
3answers
2k views

what is total in the output of ls command [duplicate]

Possible Duplicate: ls command: what does the first line mean? I have an empty directory.I am using following command to view the contents of that directory. ls -lart The output I get is ...
4
votes
4answers
318 views

List any file ending with .in and corresponding .out with shell script

I have a directory full of files ending with different extensions, how would I list/select only the files ending with .in and corresponding .out that share the same basename? e.g. file1.txt file1.in ...
5
votes
1answer
457 views

Why could the size of the “dot file” /. exceed 4096?

Today I found an "empty" directory with a size of 4MB. It had no visible contents, so I tried ls -lah. This showed me some hidden files (not very large). Searching for the reason why the directory ...
5
votes
3answers
176 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
4answers
6k 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 ?
1
vote
1answer
526 views

Very basic question, ls a different directory and save file

I seriously can't understand where I'm going wrong with his question. The first part is. List all the file and directory names in /etc which have 1 or more numbers in their name. Remember to use ...
1
vote
1answer
3k views

Alias for directory listing sorted by time modified in reverse order

When I need to find my recently used files, this command: ls -lt lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because wont fit in ...
3
votes
2answers
124 views

Make ls distinguish scripts from binaries in output

Is it possible to make ls distinguish executable scripts from actual compiled binaries? The permissions are most often the same (+x), and with ls -F you get an asterisk suffix (*) for both, so it's ...
3
votes
1answer
785 views

What's the second column of ls -l say? [duplicate]

Possible Duplicate: What is the number between file permission and owner in ls -l command output? I've been using Linux for years now and I'm embarrassed to say that until now I didn't ...
11
votes
5answers
8k 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.
5
votes
1answer
148 views

Alphabetizing names in `ls` alias with .files not intermingled

I am currently using the following ls alias: alias ls='ls -alhGkpsq --color=auto'. This results in following directory listing. [03:35] bryson@brys ~ :$ ls total 48K 4.0K drwx------ 4 bryson 4.0K ...
1
vote
1answer
919 views

cannot 'ls' /mnt directory

I have a CentOS-6 machine that I'm working on that is running a live database. It's having a problem with the /mnt directory. I cannot ls the directory for some reason. stat is working and shows ...
3
votes
2answers
485 views

Why is bash giving me (apparently) conflicting information about a file?

Background I am working on a RHEL 5 cluster. I want my Fortran program to read the file /home/bob/inputs/input_1 I asked Bob to give me permission to read all contents of inputs: [bob@server]$ ...
1
vote
4answers
500 views

No such file or directory error when using xargs

I have some files with .mkv extension and I want to calculate their total size using du -h. Some of the files are preceded by whitespace characters. ranveer@ranveer:~$ ls *.mkv ...
1
vote
1answer
394 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 ...
4
votes
2answers
527 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 ...
2
votes
5answers
5k 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 ...
1
vote
2answers
283 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
3answers
901 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
6answers
2k 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 ...
8
votes
1answer
465 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 ...
5
votes
1answer
350 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
1k 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
475 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
648 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 ...
14
votes
6answers
9k 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
385 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
572 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+ ...
6
votes
7answers
7k 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
743 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
1k 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 ...
10
votes
6answers
4k 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
538 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.
7
votes
2answers
1k 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
446 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
686 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 ...
12
votes
2answers
975 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
128 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
420 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. ...