Tagged Questions

The ls command lists the contents of a directory.

learn more… | top users | synonyms

2
votes
2answers
285 views

Difference between `ls -c` and `ls -t`

What is the difference between -c and -t options for the ls Unix command? And how can I sort by date of creation with the ls command?
3
votes
6answers
479 views

ls content of a directory ignoring symlinks

I have a directory in which I would like to list all the content (files and sub directories) without showing the symbolic links. I am using GNU utilities on Linux. The ls version is 8.13. Example: ...
1
vote
3answers
182 views

Removing a directory that has no files in it

I recently created a username and a group called gamesForAdmin. Since then I deleted it and the folder I made for it is still there: drwxr-xr-x 5 root root 4096 Jul 4 11:28 . drwxr-xr-x ...
2
votes
4answers
794 views

Sort the output of find -exec ls

Is it possible to the output of find … -exec ls -ls ; sorted alpabetically, by filename? This is my cron command: find /home/setefgge/public_html -type f -ctime -1 -exec ls -ls {} \; This command ...
2
votes
3answers
277 views

When was a file last opened?

How do I determine, when a file was last opened? I've looked at man ls (using GNU coreutils 8.22) and I don't see anything about this timestamp.
1
vote
1answer
357 views

ls shows a timestamp with no time for a file on NFS

When we create a file on Linux we notice that the timestamp is not visible and the stat on the file shows a time in future, the filesystem is an NFS mount, has anyone seen this before? ...
6
votes
1answer
117 views

Filetype and dereference when listing directory with LS command

I'm trying to combine arguments to the ls command to list a directory content. What I'm basically trying to achieve is listing the directory dereferencing all links, but showing explicitly that the ...
3
votes
1answer
67 views

`echo test?` prints `test2` but `ls test?` prints nothing

I was playing with bash globbing recently and I noticed the following: First, make 2 dirs: $ mkdir test $ mkdir test2 Then: $ echo test? Outputs (correctly): test2 But: $ ls test? Outputs ...
2
votes
1answer
64 views

limitation on count of records returned by ls -lrt

Is there any limitation on count of records returned by ls -lrt? I am seeing problem of crash in OEL 4.7 environment where my ls -lrt command may return more than 100K records.
2
votes
0answers
105 views

ls does not show a hidden file (OS X)

I am using lsof to view the list of open files. One such file that it displays open is : Google 3864 malaykeshav 46u REG 1,1 470455334 32578671 ...
2
votes
1answer
81 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
173 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
2k 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
48 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
433 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
274 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 ...
0
votes
1answer
69 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
358 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
606 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
160 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
252 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.
0
votes
3answers
74 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 ...
1
vote
1answer
70 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
572 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".
76
votes
8answers
10k views

Why *not* parse `ls`?

I consistently see answers quoting this link stating definitively "Don't parse ls!" This bothers me for a couple of reasons: It seems the information in that link has been accepted wholesale with ...
5
votes
2answers
371 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
2answers
76 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. [ ...
1
vote
2answers
49 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 ...
-1
votes
4answers
382 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
175 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
1k 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 ...
1
vote
1answer
78 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 ...
0
votes
2answers
284 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 ...
5
votes
2answers
117 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
51 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
176 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 ...
5
votes
2answers
991 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
305 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
93 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
354 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
104 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 ...
0
votes
1answer
40 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
226 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 ...
7
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 ...
4
votes
3answers
561 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
2k 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 ...