The ls command lists the contents of a directory.

learn more… | top users | synonyms

0
votes
3answers
65 views

How to print only certain characters?

I have to translate the permissions of a file this way: r ► c w ► s x ► e Then, I must extract the group of characters which are related to owner group. Last step is to print that group of ...
0
votes
2answers
31 views

How can I recover disk space shown by the difference in disk usage between ls and du

I have a one Terabyte external hard disk drive that I intend (should have done this long ago) to use for backups, and I have done a lot of experimenting to get my mind round it. When I looked again ...
0
votes
1answer
40 views

How can I write an alias for cd such that it will fire ls after going into the directory to which I just cd'ed into? [duplicate]

Lets say I want to do cd home and then ls -lrth. I want these two things combined into a single command. I tried writing an alias, but it didnt work. Can you help me ?
-2
votes
1answer
113 views

`ls ..` and `cd ..;ls` command shows different output [closed]

I use the command ls in the same position, but it shows different output. From /usr/local/services/video_sphinx-1.0. ls -a and ls -a ../video_sphinx-1.0/ command shows different files. Why? ...
2
votes
3answers
51 views

Remove files from listing that are created/modified on Saturday

I am not sure if it is possible. I do ls -l, it gives all the files in the current directory. Is there a way to say list only files that weren't created/modified on Saturday's with shell command?
2
votes
3answers
52 views

How to know list of directories under a filesystem?

If I run sudo df -h command, I got below output: Filesystem Size Used Avail Use% Mounted on /dev/sda2 12G 9.5G 1.1G 91% / /dev/sda4 3.8G 1.5G 2.1G 41% /home ...
1
vote
1answer
30 views

Ls -1 Command in linux on Ubuntu dosen't show details beside the name of each directory or file in the list? [closed]

I am using Ubuntu and when i issue this ls -1 command there is no details appear in-front of the directories and files names there is only a blank space ..what can cause this ?
0
votes
0answers
28 views

Failed to list directory contents: process waits infinitely

I use Linux Mint 13, and sometimes (rarely) I find myself not being able to list my home directory contents. When I try to do so: $ cd $ ls then, ls just waits indefinitely. The same with any other ...
2
votes
2answers
44 views

ls doesn't give me the same as cd + ls to the same folder

$> ls ../../../../.. Doesn't give me the same result as $> cd ../../../../.. $> ls Why? Something with links? What's going on? [ johanrj@jamin ] ...
4
votes
2answers
428 views

Basic commands in Unix not working i.e: -bash: ls: No such file or directory

I'm new to Unix and in the process of installing a program for my dissertation I must have played with the PATH for the basic Unix commands such as ls. Every time I type ls and the directory name I ...
3
votes
4answers
71 views

Determining the number of files and subdirectories in Linux

When displaying directories in linux using ls -ld, I get something like this: user@shell:~/somedirectory$ ls -ld drwxr-xr-x 2014 K-rock users 65536 20011-11-05 11:34 user@shell:~/somedirectory$ ...
1
vote
3answers
50 views

Print full pathname with `ls` and `find`

I want ls to print with absolute pathnames, how do I do that? find / -type d -mount -exec ls -ls {} \; ls is printing only the relative file names within the directory.
4
votes
6answers
268 views

How can I list files by type with ls?

When I use the ls command with the option -l, the first string of letters gives the info about each file, and the first letter in this string gives the file's type. (d = directory, - = standard file, ...
1
vote
2answers
66 views

how to sort files by their permissions using ls?

I have a large number of files and directories in one directory. I need to sort them in terms of the permissions. For example drwx------ drwxr-xr-x drwxr-x--- I am just wondering if we can sort ...
3
votes
1answer
57 views

Changing the spacing between files in ls

This is more of a cosmetic question but this is really bugging me. On OS X, when I run ls -G (or use CLICOLOR=1) instead of regular ls it changes the spacing of the columns, as you can see in this ...
3
votes
5answers
101 views

List files with line count and date

I want to be able to list files showing the number of lines the each file has and the date. I can happily get the line count using wc -l *. Not a problem. I can get the date using ls -l. Is there a ...
3
votes
1answer
312 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
90 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
38 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
122 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
43 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
156 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
55 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
31 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
84 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
147 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
77 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
114 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
203 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
49 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 ...
0
votes
1answer
88 views

Delete empty directories using 'ls' command

I want to delete empty directories without using find command find . -empty -type d -delete. like the following: if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi How do I ...
-2
votes
1answer
104 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
3k 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
57 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
98 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
42 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
26 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
100 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
733 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
689 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
353 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
164 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
921 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
61 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
149 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
102 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
189 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
177 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 ...