The ls command lists the contents of a directory.

learn more… | top users | synonyms

5
votes
2answers
1k 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?
2
votes
1answer
86 views

List directories with dot directories last, then dot files

I'm aware of the ls option --group-directories-first but that's not exactly what I want to achieve. The output should be: (sorted by name ASC) Directories Hidden Directories Hidden Files
2
votes
3answers
186 views

Strange formatting of date in bash script

I am working on a script to sort my downloads folder by the date the files were created. This is the script I am using: #!/bin/bash cd ~/Downloads for FILENAME in * do if [[ -f $FILENAME ]]; ...
1
vote
3answers
3k views

Difference between ls -l and ll?

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but ...
0
votes
1answer
49 views

Why do these 2 find commands give differnt results?

I wanted to see all files modified within the last 10 days and who owned them, so i entered the following to give me an idea how many results would be returned; find . -maxdepth 1 -mtime -10 I then ...
1
vote
1answer
550 views

How to change the output color of ls comman in terminal in OS X and iTerm2?

I know that a similar question has been as in: How to colorize output of ls ? Though, I didn't really understand the answer and couldn't really make it work. However, I have tried something ...
2
votes
4answers
472 views

Get the latest directory (not the latest file)

My folder parent has the following content: A.Folder B.Folder C.File It has both folders and files inside. B.Folder is newer. Now I just want to get B.Folder, how could I achieve this? I tried ...
19
votes
5answers
30k 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.
3
votes
7answers
5k views

Convert ls -l output format to chmod format

Say I have the following output from ls -l: drwxr-xr-x 2 root root 4096 Apr 7 17:21 foo How can I automatically convert this to the format used by chmod? For example: $ echo drwxr-xr-x | ...
0
votes
1answer
81 views

How to get the same ls with colors working on both OSX and Ubuntu?

When I want color in Ubuntu I do alias ls='ls --color=always' but on OSX this gives an error ls: illegal option -- - and I need to do alias ls ='ls -G' How can I create an alias with the same ...
4
votes
4answers
455 views

What is the Linux command to display how many file names in the directory end in two digits

What is the Linux command to display how many file names in the directory end in two digits? Using ls with a command like this : ls -l | wc –l *[0-9][0-9]
5
votes
3answers
640 views

Linux command to return all files that start with TEMP but do not end with double digits

What is the Linux command to return all files that start with TEMP but do not end with double digits? I think it should look something like this: ls -l TEMP*[!0-9][!0-9] but the results of my ...
3
votes
5answers
163 views

Look if a folder has some files of certain extention

Lets say I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and look if they have any .pdf files. Could some one please ...
4
votes
3answers
256 views

What does “command1 -> command2” indicate in results from my ls -al?

when I do a ls -al in /usr/sfw/bin I see: make -> gmake What does this indicate? Is this a symbolic link? I've googled and have not found the answer to this question.
5
votes
2answers
409 views

Why doesn't my loop over the output of ls work?

I am trying to feed Directory names into a for loop. My code is as follows: td='/Test/TopDir/' cd "$td" for x in $(ls -d */ | cut -f1 -d'/'); do echo x=$x done The top directory I run this on ...
0
votes
3answers
75 views

“Other” permissions on files

To my understanding, the last three character of file permission printed by ls command is about other user's file permission. If the other user"s" have separate file permissions to this file, what ...
6
votes
4answers
15k 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 ...
1
vote
1answer
73 views

GeeXbox ls shows no date?

Recently, I tried connecting to my GeeXbox via WinSCP but got an error indicating the output of ls could not be parsed. Apparently, my ls does not include a time stamp! What might be the cause and ...
0
votes
6answers
862 views

How to list files starting with “a” or “c” from /etc.

I tried ls /etc/[ac]* but it shows directories starting with a or c, and their entire contents, not the files starting with "a" or "c".
9
votes
3answers
2k views

Why is sorting files by access time not working?

I tried to use command ls --time=atime it was working in one directory but wasn't working in another directory. I opened certain files in vim, evince and other applications but after the command file ...
0
votes
2answers
81 views

How can I shorten an if then else using the [] format

I want to shorten this to a one liner: if ls --version 2>/dev/null | grep -q 'coreutils'; then alias ls='ls --color=always' else alias ls='ls -G' fi I frequently use [] for conditionals, e.g. [ ...
15
votes
7answers
11k 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 ...
10
votes
2answers
9k views

What causes this green background in ls output?

There are two directories shown by 'ls'. Normally directories anywhere are blue on black background. But the first one is blue on green and impossible to read. Why is this? How to make it blue ...
12
votes
6answers
1k 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?
1
vote
2answers
52 views

`ls` fails for directory copied from Win and OSX [closed]

I'm not able to ls on a folder that I have just transferred from win7 to OSX via a FAT32 drive. I don't know how to search for an answer for this issue. I've attempted the following: sudo chmod ...
16
votes
4answers
16k 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?
-1
votes
4answers
532 views

How to exclude directories from `ls -R` output?

If ls -aR | grep ":$" returns ./.hiddendir2: ./dir1: ./dir3: ./dir3/.hiddendir4: then how can you update the pattern given to grep so that you only get ./dir1: ./dir3: (note that the last ...
3
votes
1answer
189 views

“The entry is a door” in Solaris “ls” man page

I found this in a man page for ls in solaris linux. http://www.unix.com/man-page/opensolaris/1/ls/ What does it mean when it says: D the entry is a door?
9
votes
3answers
2k views

EXT3: If block size is 4K, why does ls -l show file sizes below that?

If you run ls -l on a file that contains one letter, it will list as 2B in size. If your file system is in 4k blocks, I thought it rounded files up to the block size? Is it because ls -l actually ...
0
votes
2answers
347 views

Bash: iterate with variable on the lines of `ls -1` output

In a simple cycle like the following for f in $(ls -1) ; do something done I would like to store each line of the output of ls -1 in the variable f. Is there a way to do this ...
1
vote
1answer
84 views

Leave directory out using ls

I am trying to get a vertical list from ls, that is recursive but leaves a out a single directory called node_modules. I've used: ls -lt -h -R This gets me a very long list that is vertical, human ...
5
votes
2answers
118 views

ls command: how to ignore case without globbing

I use the shopt -s nocaseglob command to ignore case, but it seems like it doesn't work if I use a string without glob. Just a question out of curiosity, is it possible to ignore case without ...
7
votes
6answers
1k 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
53 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
2k 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
195 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
1k 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
92 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, ...
29
votes
2answers
27k 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.
3
votes
3answers
329 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
99 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
360 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
111 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
29 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
4answers
4k 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 ...
3
votes
2answers
7k 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
42 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
328 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
178 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 ...
6
votes
2answers
582 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 ...