The ls command lists the contents of a directory.

learn more… | top users | synonyms

7
votes
6answers
596 views

Is it possible to remove folder prefix from a `ls` command

I am in a bash script and I want to get the list of all files (let say all jar files). I execute the command ls -1 lib/*.jar and I get the output: lib/mylib_1.jar lib/mylib_2.jar ... Is there any ...
3
votes
1answer
33 views

Customize bash to always include a certain parameter

When using the "ls" command, bash prints in the following format: file1 file2 file3 file4 file5 file6 file7 file8 But when given the parameter "-1", it prints: file1 file2 file3 etc... Is there ...
1
vote
3answers
64 views

How to display “human-readable” file sizes in find results?

I'm trying to find all large files on my Centos server. To do that I'm using: find / -maxdepth 10 -size +100000 -ls I tried changing -ls to -lsh but it is not allowed. How can I display these ...
3
votes
1answer
52 views

ls --color: how to color executable hard links?

I created some hardlinks on an NTFS drive, but because of that, they are all executable and colored as executable instead of as hardlinks (regular file with more than one link). I did a test on my ...
3
votes
2answers
532 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.
3
votes
2answers
73 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, ...
25
votes
2answers
17k views

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
5
votes
2answers
212 views

How do I find the inode of any directory?

There is literally nothing on google that I can find that will help me answer this question. I presume it is passing some other parameter to ls -i?
3
votes
3answers
145 views

Why do ls and hexdump disagree about my file size?

I have a file I created (in vim), for testing purposes (testing UTF-8 output in an SSH client). Odd things, however, are happening to this file. I wondered what bytes were in the file, so I used ...
1
vote
2answers
28 views

File not displayed using vi but visible with command ls -l CD*

I can do an ls -l CD* and see the following output. CDTEST userA RW RW R I am logged in as userA. But if I do an ls -l the file does not appear. If I do vi CDTEST it tries to create a new file ...
7
votes
2answers
290 views

Symbol that will show up first in output of `ls`?

I want a folder called DELETED to be first in my output of ls. Is there a symbol I can add to the front that can cause this? I've tried ^ and - and neither works.
1
vote
2answers
54 views

difference between “ls –alR /” and “ls –alR / &”? [duplicate]

What is the difference between "ls –alR /" and "ls –alR / &"? I seem to get the same out put. but the & sign i think should run it in background?
1
vote
1answer
25 views

“ls -lH” not following the link but “ls -lH linktofile” following it

In a directory there is a link to some other file in some other directory. If I give ls -lHh command with no arguments, ls does not resolves the symbolic link but if I give ls -lHh * or ls ...
32
votes
6answers
3k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
28
votes
4answers
966 views

The ls command is not working for a directory with a huge number of files

I had a directory which had around 5 million files. When I tried to run the ls command from inside this directory, my system consumed a huge amount of memory and it hung after sometime. Is there an ...
2
votes
2answers
3k 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 ...
0
votes
1answer
31 views

Is it possible to have total no. of blocks taken by same files be different on two PCs? [closed]

I used ls -l mysoftware/ on two different machines, each running ubuntu 12.04. But the 'total' returned by this command is different on the two machines. On one machine it is printing 6, and on ...
3
votes
2answers
43 views

What means the s in ls file permissions? [duplicate]

Have a quick question. Please see the below line ls -al -rws---r-x 1 root root 21872 2009-10-13 21:06 prg1 Compared to this -rwx---r-x 1 root root 21872 2009-10-13 21:06 prg2 That first line ...
0
votes
2answers
115 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 ...
7
votes
2answers
564 views

Why “ls” doesnt show the file that “find” discovered ?

(New to unix) In ubuntu When I am up in "/" folder i type sudo find . -name .erlang.cookie and the result is ./var/lib/rabbitmq/.erlang.cookie then when I am on the folder - /var/lib/rabbitmq ...
4
votes
3answers
425 views

What does 'l' in file metadata mean

When we type ls -l, we get meta data regarding all the objects in the current directory. The meta data has 10 dashes and the 1st dash indicates if the object is a directory or file or a link d ...
5
votes
4answers
398 views

maximum number of files ls can list [duplicate]

Im using a script to delete old file in a directory, but the script kept showing /usr/bin : Argument list too long It turned out the number of files were 40000 and more, So I want to know what is ...
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 . ...
0
votes
1answer
45 views

Understanding ls -l output

When I run ls -lrt command on a Unix folder , I get the following output MyServer> ls -lrt total 10 drwxr-x--- 3 UnixUser other 512 Jul 22 2011 FolderA lrwxrwxrwx 1 UnixUser other ...
5
votes
2answers
100 views

ls for cut -f string not working

I have a problem with feeding cut output to ls. This doesn't work: rep="S1_1000,0000-00-00c,0000-00-00d,0000-00-00e" ls tab_yeast/{`echo $rep | cut -f2- -d','`}*.tab.gz ls: cannot access ...
7
votes
2answers
692 views

Is there a correct way to list the subdirectories of the current directory?

I can find the subdirectories of a directory by ls -d -- */ or ls -l | grep "^d" but both of these seem indirect, and I would imagine that there would be a standard way to find just the ...
10
votes
6answers
25k 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 ...
18
votes
2answers
3k views

ls command: what does the first line mean?

When I do ls -l I get this: calico@A000505:~/Documentos$ ls -l total 2020 -rwxr-xr-x 1 calico calico 8559 2010-11-16 11:12 a.out -rwxrw-rw- 1 smt smt 2050138 2010-10-14 10:40 Java2.pdf ...
9
votes
5answers
10k views

Linux ls to show only filename date and size

How can I use ls in linux to get a listing of filenames date and size only. I don't need to see the other info such as owner or permission. Is this possible?
11
votes
3answers
7k views

What is the Linux equivalent of DOS “dir /s /b filename”?

List all files/dirs in or below the current directory that match 'filename'.
1
vote
1answer
66 views

Linux ls wrong date format

I try to find why when I do the command ls or whatever ls -la the column format is wrong with date. It should be like that: -rw-r--r-- 1 johndoe johndoe 55 janv. 26 2011 not like that : ...
2
votes
2answers
57 views

Very strange ls > textfile problem when viewing with emacs

I want to list the components of the current working directory in a text file ls -1 > textfile Output looks fine with more. 1010661085645 1010729039145 1010747080245 1010849051345 ...
1
vote
1answer
37 views

ls: show file size with thousand separator [duplicate]

Is there some simple way to make ls display the file size number with thousand (and million, billion, ...) separator? A sample output should look like this: $ ls -lAF /bin/ -rwxr-xr-x 1 root root ...
6
votes
4answers
817 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 ...
-1
votes
3answers
120 views

Use of ls with wc command

What does the command : ls | wc -l do? I know wc <filename> gives lines, words, and characters, and wc -l <filename> print the line count. But how it is being used with ls` ...
18
votes
2answers
515 views

Is there a reason why ls does not have a --zero or -0 option

This question was prompted by questions about ls' -1 option and the recurring tendency of people to ask question and answers that includes processing the output of ls. This reuse of the output ls ...
1
vote
3answers
98 views

Where is “showing the output of the 'ls' command vertically” documented?

I found out it's possible to show the output of the ls command vertically using the -1 switch: $ ls -1 But couldn't find it in the manual of ls. Is it a secret option?
1
vote
0answers
32 views

Display full ISO time in OSF1

I am working on an HP OSF1 (Tru64) based server and need to display file listings with the full-iso time format style. Example of this in Ubuntu Linux, user@hostname:~/Desktop$ ls -lrt --full-time ...
4
votes
1answer
40 views

ls -l --group-directories-first (act on symlinks as well)

ls option --group-directories-first causes directories to be listed on the top, which makes the output of ls nice and clean: ls -l --group-directories-first However, it does not act on symlinks, ...
8
votes
1answer
12k views

How can I assign the result of a command to a shell variable?

I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; ...
11
votes
1answer
115 views

Include colouring in GNU ls time-style

I know, I can specify custom time format for ls like this ls -lAF --time-style="+ %Y-%b-%d %H:%M:%S" --color=always but I would like to "smuggle in" colors inside the time format. For example, I ...
12
votes
6answers
651 views

Why does “ls” require a separate process for executing?

Why does ls require a separate process for its execution? I know the reason why commands like cd can't be executed by forking mechanism but is there any harm if ls is executed without forking?
2
votes
3answers
109 views

Preserving color output with cut

Using bash interactively I am trying to use cut to prevent the lines from going longer than my terminal width. But when using a command with colorized output all the color gets removed by cut. For ...
2
votes
3answers
106 views

Count number of characters per listed filename

Given the following ls result: $ ls Desktop Documents Downloads Music Pictures Public Templates Videos This will give the total number of characters for all files: $ ls | wc -m 67 But how ...
6
votes
5answers
3k views

Show sum of file sizes in directory listing

The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current ...
3
votes
2answers
89 views

dot instead of comma as thousand separator

I read about --blocksize for ls to get a thousands separator. However my computer gives me dot (.) and not comma (,): $ ls -l --block-size="'1" total 11.893.190.656 -rw------- 1 carlah users ...
-1
votes
3answers
3k views

Human-readable ls output under AIX?

How can I get human-readable ls output under AIX? There is no -h parameter
3
votes
1answer
42 views

= sign at the end of .sock files in the ls output

I'm running the zsh shell in emacs. When I run ls I get a = at the end of .sock files. What does the = mean? Is it unique to unix sockets?
1
vote
3answers
119 views

How to turn off color with `ls`?

It is normally nice to have color output from ls, grep, etc. But when you don't want it, is there a switch that can turn it off? ls -G turns it on (with BSD-derived versions of ls) if it's not the ...
1
vote
2answers
677 views

Differing outputs of the commands “ls .*” and “ls *.”

The command ls .* when run gives as output the following : All the files in the current directory starting with a . (hidden files) All the files in the hidden directories present in the ...