The ls command lists the contents of a directory.

learn more… | top users | synonyms

0
votes
1answer
45 views

Linux can't read and write, but windows can

I have a hard drive with a lot of back up files, that were created by PhotoRec. When mounting it with a windows computer I can read all the files perfectly fine. Under linux I get an error when ...
1
vote
2answers
36 views

How do I find a files directory?

I am looking for a specific file in OS/X. I can see the file by using: ls -alR | grep "mkmf.*" This shows my that the file exists. How do I find what directory the file is located. Many thanks ...
2
votes
1answer
25 views

Regarding identical copies of gedit files

When ever I save a gedit file in a directory, two copies of it get saved with identical content. Ex: If the gedit file is named as file_name and saved in Home directory then when u ls the Home ...
3
votes
2answers
85 views

exit a script if an ls line did not find any match

I am writing this script that have this line: ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable What I wanted is to exit the script (without using if-statement) if it ...
5
votes
3answers
227 views

Sorting ls output by time, when there are too many files for a single invocation

I know that I can sort the output of ls by time with the -t option. I know that when I have so many files that they don't fit in a single ls invocation, I can normally use xargs (or find ... -exec ...
12
votes
4answers
676 views

Why does ls accept duplicate switches?

I'm curious - is there a difference between ls -l and ls -lllllllllllllllllllllllllllll? The output appears to be the same and I'm confused on why ls allows duplicate switches. Is this a standard ...
1
vote
3answers
63 views

Why is ls command slow to interrupt on NFS directory with lots of files?

I noticed in directories with lots of files on NFS if I do ls * then hit Ctrl-C it can take a while ( say 20 seconds ) before ls comes back. Why? Can ls command be fixed to be more responsive?
0
votes
1answer
33 views

ls command - list files containg speccific string in file name and belong to specific type

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will ...
7
votes
2answers
867 views

Which is more efficient, ls or ls -l?

As I understand, the ls command calls getdents, which returns up to x number of directory entries. Are there any other system calls involved? If I run ls -l, are there any more system calls? I am ...
3
votes
1answer
39 views

Fine-tune LS_COLORS for directory suffixes?

I’m fine customizing most settings in LS_COLORS. I don’t need help customizing the colors for different file suffixes. What I would like to do is configure special colors for certain directories, ...
0
votes
1answer
50 views

Piping the output of ls or tree to less loses colors? [duplicate]

tree and ls can distinct file types by coloring filenames differently. tree and ls often output a long list of files (including directories), so I pipe the stdout output to less. But less doesn't ...
0
votes
0answers
15 views

What are differences between directory order and alphebetic order with `ls`? [duplicate]

What are differences between directory order (-U) and alphabetic order (by default) with ls? They return the same order of a dir's contents to me.
0
votes
3answers
51 views

List files of certain type under a dir?

If you want to list just directories (in the present directory) use ls -d */ What if you want to list just ordinary files, just executable files, or just soft links, or files of any other type? ...
3
votes
1answer
172 views

The -F option for ls

For command ls -F, --classify append indicator (one of */=>@|) to entries Wikipedia says * represents executable and / dir. Regular files are not followed by any of the above ...
3
votes
2answers
131 views

Valgrind /usr/lib files are not regular Linux files

The problem that I encountered today (on an embedded device with Linux) is that some files (specifically, the Valgrind /usr/lib files) are behaving very strange and they are not copy-able with scp ...
1
vote
2answers
92 views

-bash: cd: .ssh/: Permission denied

When I type in cd .ssh in terminal, it returns with -bash: cd: .ssh/: Permission denied. Now I cannot add my ssh keys to ssh. When I type ssh-add ~/.ssh/idname it says /Users/Dan/.ssh/idname: ...
2
votes
2answers
137 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
158 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
153 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
124 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
257 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
117 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
74 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
53 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
55 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
81 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 ...
3
votes
1answer
67 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
108 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
512 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
33 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
121 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
80 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
47 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
199 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
405 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
131 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
242 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
70 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
54 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
138 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".
70
votes
8answers
9k 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
279 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
59 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
42 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
106 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 ...
2
votes
1answer
107 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
884 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
56 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
134 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
96 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 ...