The ls command lists the contents of a directory.

learn more… | top users | synonyms

3
votes
1answer
274 views

It's bad to use ls -A to list hidden files?

I want to list every file, including hidden files, in the current directory. I don't want to include the parent (..) and current (.) directory. I found this: how to glob every hidden file except ...
3
votes
3answers
50 views

Sorting directories by last modified date/time of the same-named contained file

Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example: domain1/file.php (last modified 20-Jan-2014 ...
0
votes
1answer
30 views

Executable directory? And chmod o+w changing the terminal directory color?

What does an executable directory mean? If o+w is set the directory changes colors to a background green, what does this mean? Why doesn't it do it for ug+w, but only for o+w? Additional question ...
0
votes
2answers
114 views

proper way to iterate through contents in a directory [duplicate]

I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files ...
-1
votes
2answers
32 views

Matching multiple patterns with ls

I'd like to get a list of fail logs in the current directory for use in an outside script, the logs are determined with the pattern FAIL in the filename, so I've been using a FAIL* to feed my script ...
1
vote
2answers
149 views

sort and ls — why aren't capitalized letters sorted first?

I want a sorting like this, with capitalized letters before lowercase: -rw-r--r--. 1 0 0 183 2014-10-14 20:17 ./CHECKSUMS.md5 -rw-r--r--. 1 0 0 185 2014-10-14 20:17 ./CHECKSUMS.asc ...
0
votes
2answers
45 views

ls hard link question

I run ls -la on the Volumes directory. It shows the MM dir to have 9 hard links and the Media dir to have 12. If I then cd to the MM directory and run ls -la, it shows only 7 items whereas if I cd to ...
1
vote
2answers
28 views

Listing folder contents during cd command

I might be mistaken here, but I was watching someone navigate using the cd command, and without actually executing it, they were able to show the folder contents of the current folder. So if I type ...
6
votes
1answer
75 views

???? files in ls -l output

I see ghost files in red colour inside some of my directories: [drey@cyan|23:54|~/downloads]ls -la ls: cannot access teamviewer9_linux.deb: No such file or directory total 1318096 drwxrwx--- 1 root ...
2
votes
2answers
66 views

Change file timestamp and display hour instead of year with ls

I want to change a file's date to tomorrow 21:00. I used touch, but when I type ls -l the year of the file is displayed instead of the hour. -rw-r--r-- 1 ABCD DEF 0 sept. 30 2014 test01 -r-xr-xr-x ...
15
votes
4answers
2k views

Why does “ls | wc -l” show the correct number of files in current directory?

Trying to count number of files in current directory, I found ls -1 | wc -l, which means: send the list of files (where every filename is printed in a new line) to the input of wc, where -l will count ...
0
votes
1answer
55 views

External Hard Drive Issue on mac

After the cd /Volumes command when I type ls it shows me my hard drive name twice, with different permissions. After that when I try to use mkdir to create a directory in the external hard drive I'm ...
5
votes
1answer
104 views

How to colourise hidden files in `ls` file listings?

LS_COLORS environmental variable lets you decide on colours for different file types for ls command, such as, directories, regular files, links etc. I suppose that dot files are considered a variation ...
3
votes
1answer
149 views

Putting Files in Ascending order (not on time stamp basis) in Unix [closed]

How do I list files in Ascending manner, not on time stamp basis. EX:- Original listing A_2001 A_2002 A_2003 A_2004 B_2001 B_2002 B_2003 B_2004 Desired output:- A_2001 B_2001 A_2002 B_2002 ...
0
votes
1answer
42 views

Difference between “ls -l” and “dir -l” [duplicate]

What is the difference between ls -l and dir -l? I always use ls -l, but my colleague (who is slightly colour blind) uses dir -l. Is this the only difference: ls -l has colour and dir -l not have ...
-2
votes
1answer
53 views

Delete empty directories without find

I want to delete empty directories without using find command like the following: Instead of find . -empty -type d -delete use if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi ...
-3
votes
1answer
82 views

Find files using ls and wildcards

pwd : ../bin under bin I have a directory called datafiles. Use meta characters and the ls -lL command (with lower and upper case L) to list all filenames under the datafiles directory that contain a ...
31
votes
1answer
2k views

Why can Linux show a file name containing character '/'?

The following picture is snapped in a real Linux environment. Why can Linux show a file name containing character '/'?
1
vote
1answer
50 views

ls and find command excluding a certain directory

I want to do this: ls -altrhS 'find / -type d \( ! -name tmp -prune \) -size +10000k 2> /dev/null -print' | egrep -v 'ibd|MYD|MYI' So I want to list, in that format, files of a specific size ...
0
votes
1answer
74 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
41 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
94 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
561 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
686 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
239 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
83 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
906 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
55 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, ...
1
vote
1answer
100 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
72 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
185 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
161 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
512 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
210 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
275 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
169 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
496 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
271 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
265 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
104 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
62 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
61 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
98 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
74 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
158 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
1k 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
41 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
320 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 ...