Questions tagged [ls]

The ls command lists the contents of a directory.

Filter by
Sorted by
Tagged with
0
votes
2answers
42 views

Allow only ls on directories

how can I set permissions to a folder so all users not in my group, can only do ls on it? I don't get the difference between - and r.
0
votes
3answers
156 views

Piping ls to grep. Why does grep disregard the output from the ls command?

I am trying to use this command ls -p | egrep "\<[A-Z]+\>" to print all uppercase file and dir names with dir names having / appended. I do not understand why my command works even though I said ...
1
vote
0answers
68 views

bash colored completion doesn't obey LS_COLORS environment variable

In bash, I have colored output set up for commands such as ls. I customized the exact colors used with the LS_COLORS environment variable, since the default ones were kind of ugly. From what I ...
5
votes
2answers
6k views

`ls -lS` isn't showing true size of directory

I used ls -lS command in my home directory. This command is supposed to list down the contents of a directory by size. This is what I got after running this command total 10148 -rw-rw-r-- 1 rahul ...
1
vote
0answers
42 views

Why is one directory's file larger than 4kB? [duplicate]

I have a directory on my EXT4 filesystem that's showing up as larger than the usual 4kB: $ ls -l total 24 drwxrwxr-x 2 jvilla jvilla 4096 May 24 17:57 'Season 1' drwxrwxr-x 2 jvilla jvilla 12288 Sep ...
1
vote
1answer
106 views

How does ls --tab-size work?

I can't figure out what does ls --tab-size=COLS (or ls -T<COLS>) do. From man: assume tab stops at each COLS instead of 8 And, for instance, what's going on here? Or what would be a useful ...
0
votes
2answers
140 views

How can I brighten up blue directories in ls --color?

I see one other Dark blue color...-Q with the same problem: Instead of two kinds of blue (normal and bright/bold) I have only one, very hard-to-read so-called "bold blue". Normal blue is even worse, ...
1
vote
3answers
173 views

Setting LS_COLORS has no effect

when using ls the directories are in a really hard to read navy blue, so I want to change them. I read that I need to set LS_COLORS but for me it doesn't do anything. Here's what I tried: LS_COLORS="...
1
vote
3answers
163 views

How to list all files under /etc and write it to a file in /home?

ls -a > /home/etc.txt -bash: /home/etc.txt: Permission denied I'm in /etc trying to list all the things under it and write it all into a text file in /home... but I'm getting permission denied. I ...
-2
votes
1answer
105 views

User cannot see a directory in /var/www, thought the directory is there

I'd like to create a repository folder that can be accessed by cpanel user. Let say I create a directory in /var/www/webassets, and set the access to 777. I can see the folder using ll command as ...
0
votes
0answers
115 views

How ls -lh round off the actual sizes in human readable form?

I was using the command ls -lh to see the long list of files and their sizes in human readable form but i was unable to understand one thing that how the human readable form round off the actual sizes....
1
vote
1answer
311 views

total in the output of ls -l command

I know that total tells the number of 1K blocks used by the files in directory i am working on. For some purpose i entered the command ls -lh to see this in human readable form, i saw the blocksize of ...
132
votes
8answers
301k views

List only regular files (but not directories) in current directory

I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find find . ...
-1
votes
3answers
500 views

find directory or file that ends in any 3 characters

i am trying to find directory or file that ends in any 3 characters with using ls -l /etc | grep ???$ and this doesnt work,, what should I type to find any directory of files that ends with 3 or ...
3
votes
1answer
2k views

How does Linux calculate the total block count when running /bin/ls -l?

I am trying to figure out how the program /bin/ls -l calculates the total size (block count) for a directory. By this I mean the output total number that it prints right before the directory contents. ...
2
votes
2answers
184 views

xargs combined with bash -c with multiple placeholders

I am combining ls, xargs and bash -c to run a specific program on multiple input files (whose names match the pattern barcode0[1-4].fastq. The program that I am calling with xargs is called krocus ...
32
votes
7answers
69k views

How to list all files in a directory with absolute paths

I need a file (preferably a .list file) which contains the absolute path of every file in a directory. Example dir1: file1.txt file2.txt file3.txt listOfFiles.list: /Users/haddad/dir1/file1.txt /...
0
votes
1answer
161 views

Who is setting my LS_COLORS?

I'm using the bash shell, and want to change some of my ls listing colors; I've noticed that this can be controlled using the LS_COLORS environment variable, which encodes terminal colors for various ...
-4
votes
3answers
106 views

Show only files which name starts with a specific letter

My task is to output a list of files with there attributes which names starts with 'p' letter using ls and grep. I am using ls -Rl to show list of files, like this, but I don't have an idea how to ...
0
votes
2answers
150 views

Pick randomly 30% of the files in a folder

I have a number of folders, each with audio files in it. I want to pick out 30% of each of this files and cut them (not copy) to another folder. I can see this post which can help me do this given ...
8
votes
2answers
66k views

Basic commands 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 ...
1
vote
0answers
31 views

lsattr returns different results depending on how it's run

I'm using lsattr on a linux container on the contents of a mounted drive that's been mounted using SAMBA and am seeing some interesting results. If I run lsattr in quick succession, I get differing ...
134
votes
7answers
45k views

What does the @ mean in ls -l?

I am using Mac OSX. When I type ls -l I see something like drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 ...
1
vote
1answer
64 views

What does 'mustard color' highlighted directories mean?

When I run 'ls -laGp' command in macOS some of the folders are highlighted with this color. What does that mean? I researched but couldn't find any documentation or anything. If you let me know ...
49
votes
2answers
34k views

Output from ls has newlines but displays on a single line. Why?

I think I may be overlooking a relatively fundamental point regarding shell. Output from the ls command by default separates output with newlines, but the shell displays the output on a single line. ...
0
votes
1answer
31 views

How to interpret /var/log output

I have trouble interpreting the following output from /var/log. Both lines show the same result but of different date? What does this mean? Currently doing an audit to ensure that the directories are ...
14
votes
1answer
3k views

'ls' showing two identical files in a directory

So somehow the command ls seems to be showing me two identical files in a directory. $ ls -Blah /System/Library/LaunchDaemons total 32 ...
2
votes
1answer
451 views

Problem with ls inside bash script [duplicate]

Basically I am trying to recursively list sub directories until I hit a directory where there are no more directories to be found. The problem here, is that when I pass the argument into the function,...
0
votes
0answers
35 views

why is the result of ls not sorted? [duplicate]

I have a folder of images that are numbered. ls returns them in order of most significant digit instead of numerical order. as a result comands like convert *.jpg out.pdf creates pdf in this order. ...
0
votes
0answers
16 views

mv: cannot move (not a directory) from a symlink directory [duplicate]

Trying to understand, why does ls work, when I do "ls ..TAB-TAB"? It's showing me the contents of /hukarz, but when I press ENTER after "ls ..", it's showing the contents of /foo/bar cd /hukarz ln -...
15
votes
3answers
4k views

Why did my folder names end up like this, and how can I fix this using a script?

Sorry if this has an answer elsewhere, I've no idea how to search for my problem. I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save ...
2
votes
2answers
247 views

How many possible file types in the output `ls -l` command?

usually, the possible file types in the output ls -l command are d and -, which represent directory and regular file respectively. besides above, I saw another type l in the output on macOS. drwxr-...
4
votes
2answers
10k views

View extended ACL for a file with '+' in ls -l output

A file in a ls -l listing has permissions such as: -rw-r-----+ How do I find the extended Access Control List (ACL) permissions denoted by the +?
2
votes
1answer
58 views

Is there a character that sorts before the newline character, for managing sort order in 'ls'?

I'm developing some file naming guidelines, and I'm trying to find a way to allow a draft document to list before a final revision. Example: Currently my naming convention looks like this: ...
0
votes
1answer
29 views

ls colors showing unicode replacement character

On Solaris 11.4 when I try to use ls with colors in an SSH session, the output is correctly colored but there is a question mark in a box at the end of every line like this. I tried ssh from both ...
267
votes
10answers
542k views

How to list all files ordered by size

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
1answer
379 views

Why does “sudo ls ~” show the contents of /home/username rather than /root?

When I'm logged in as username, why does sudo ls ~ show me the contents of /home/username rather than /root? I thought that sudo executes a command as root, in which case ~ would represent /root. ...
2
votes
1answer
49 views

Is ls --color falling back to precompiled LS_COLORS when using 256 color escape sequences?

I might not have found the best title for this. I am not really asking for help since I can accomplish what I want. I just want to know, if I understand everything right. But please, see for yourself: ...
51
votes
9answers
83k views

How to turn off color with `ls`?

It is normally nice to have color output from ls, grep, etc. But when you don't want it (such as in a script where you're piping the results to another command) is there a switch that can turn it off?...
0
votes
2answers
200 views

Universal abstraction of ls

Specs OS: OS X; Client: Terminal; Shells: sh, bash Problem I'm writing a shell script that adds a layer of abstraction to the ls command. I want to make it "unbreakable", so I started by figuring ...
25
votes
7answers
45k views

How to report number of files in all subdirectories?

I need to inspect all sub-directories and report how many files (without further recursion) they contain: directoryName1 numberOfFiles directoryName2 numberOfFiles
2
votes
0answers
267 views

What is the 'ls' command's output layout algorithm (how does it choose no of columns AND entries in each column)?

I have tried 'ls' command on different directories on my system, the output layout is not consistent between different directories (it is, of course, to make it human-readable-friendly). However, as ...
220
votes
8answers
39k views

Why *not* parse `ls` (and what to do instead)?

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 ...
1
vote
2answers
59 views

Can GNU `ls` color files using arbitrary filename patterns

Is there a way to specify a rule that might color every file whose name is exactly MAKEFILE red? Or perhaps any file containing the substring make (of any case) red? As far as I can tell, you can ...
2
votes
1answer
43 views

What is the precedence order of the `LS_COLORS` environment variable?

I'm aware GNU ls --color uses the LS_COLORS environment variable, but if a file satisfies two different conditions, which color is used? Just as an example, directories are executable, but they don't ...
7
votes
8answers
806 views

How to tar a list of directories only if they exist

I have a list of directories that I want to archive. But sometimes they do not all exist. I want to be able to create an archive by providing a list of directories, and it will only archive the ...
4
votes
1answer
589 views

change ls color on OpenWrt

I am not able to change the color of dir entries for ls command (dark blu is a very annoying color to read) on my OpenWrt device. I've added the line LS_COLORS=$LS_COLORS:'di=0;37:' ; export ...
0
votes
1answer
149 views

Aligning Columns to Achieve `ls -l` Style Listing with find

I'm trying to achieve the same format of listing that I get from ls -l when using find. Albeit with the full path name at the end rather than the filename. FWIW I'm using find (GNU findutils) 4.5.11. ...
86
votes
11answers
130k views

Sorting files according to size recursively

I need to find the largest files in a folder. How do I scan a folder recursively and sort the contents by size? I have tried using ls -R -S, but this lists the directories as well. I also tried ...
46
votes
11answers
67k views

Show only hidden files (dot files) in ls alias

I'm using the command ls -a | grep '^\.' for showing only the hidden files. I added the line alias hidden='ls -a | grep '^\.'' # show only hidden files to .bash_aliases file but this does not ...

1 2
3
4 5
22