Questions tagged [ls]
The ls command lists the contents of a directory.
1,357
questions
0
votes
2
answers
79
views
Where do I find documentation for the output of ls -l?
There have been multiple questions asked about this, like Understanding ls output, What are columns in ls -la?, What does 'ls -la' do?, What do the fields in ls -al output mean?, etc..
I've also come ...
0
votes
2
answers
41
views
Difference between non-graphic characters and non-printable characters
My system:
Ubuntu 22.04.3 LTS
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
man ls describes -b as follows:
-b, --escape
print C-style escapes for nongraphic characters
The ...
5
votes
1
answer
440
views
ls output display a file named "N'*" as "N'\''*"
System:
Ubuntu 22.04.3 LTS
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
ls (GNU coreutils) 8.32
Situation:
$ touch "N'*"
$ ls
'N'\''*'
"GNU Coreutils - Quoting File ...
0
votes
3
answers
2k
views
Directory listing when using setfacl ACL
I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried
setfacl -Rdm g:grouptoadd:rx /path/directory/
but, I can read files (when I use ...
0
votes
0
answers
52
views
strange error with ls on Slackware 15
Very strange error on Slackware 15 using ls
Let's see...
ls is aliased
alias ls
alias ls='/bin/ls $LS_OPTIONS'
ls return error
ls
/bin/ls: invalid option -- ' '
unalias it and works fine
unalias ls
...
15
votes
4
answers
142k
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 ...
3
votes
1
answer
96
views
'ls name' and 'ls | grep name' with accent different
I am on Xigmanas (NAS freebsd). I'll explain the situation as simply as possible:
:; set | egrep 'LC_A|LANG'
GDM_LANG=fr_FR.UTF-8
LANG=fr_FR.UTF-8
LC_ALL=fr_FR.UTF-8
SLIM_LANG=fr_FR.UTF-8
:; ls -i ...
15
votes
4
answers
48k
views
What is the meaning of ls -d?
I entered the man page of ls, the entry for the -d option is as follows:
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
So, I thought the ls -d ...
2
votes
1
answer
127
views
Why is a filename surrounded by double quotes with single quotes around a character when displayed in terminal?
Why would a file show up surrounded by double quotes with a character surrounded by single quotes within it?
"insight_automation.log'.'2024-03-13"
I am using Ubuntu Server 22.04.3 LTS. A ...
0
votes
0
answers
32
views
ls: single-column vs. multi-column layout, non-Unicode characters in filenames
Create a directory ~/test with abcdefghijklmnopqrstuvwxyz and zyxwvutsrqponmlkjihgfedcba files in it.
ls ~/test will list them using multi-column layout:
abcdefghijklmnopqrstuvwxyz ...
1
vote
0
answers
34
views
ls -g: 'man ls' says -g option has no effect, but it works
macOS 14.3, zsh 5.9 (x86_64-apple-darwin23.0). man ls:
-g: This option has no effect. It is only available for compatibility with 4.3BSD, where it was used to display the group name in the long (-l) ...
3
votes
3
answers
219
views
How does the d option for the ls command exactly work? [duplicate]
Having the following simple structure:
project
main
aaa
aaa
test
ddd
ddd
pom.xml <--- unique regular file
If the current directory is project and if is executed the ls command ...
21
votes
4
answers
59k
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 ...
7
votes
3
answers
5k
views
ZSH: `ls *(.)` lists regular files only but `ls *(/)` does not list directories only
I'm not sure I am using ZSH's globbing correctly, but I thought ls *(/) would just list the dirctories under pwd, but it doesn't, it recursively lists all files under every directory under pwd (I got ...
0
votes
0
answers
15
views
find exact match and case insensitive files on non-Windows using ansible
i'm able to find files case insensitive using the below ansible play and unix command.
- name: Check if file exists with exact name
shell: "ls {{ userfile }}"
register: filefound
...
49
votes
11
answers
167k
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
1
answer
72
views
What is the /usr/bin/dir binary on linux?
I noticed I have a /usr/bin/dir which mostly behaves like /usr/bin/ls. I assumed first it was a convenience for people coming from DOS/Windows. I assumed this would just be a softlink to ls, but my ...
11
votes
4
answers
17k
views
Show column headers with "ls" command
Does the ls command have any functionality to show the column headers for decoding what the columns are? I'm aware of the portion of support text that describes the columns in
info ls
86
votes
4
answers
35k
views
What does size of a directory mean in output of 'ls -l' command?
What does size of a directory mean in output of ls -l command?
0
votes
0
answers
66
views
Who sets the dot permission in ls -l output at build time in linux?
We have a custom build of Linux and user-land applications which contains libselinux, attr, OpenSSH, systemd, docker-ce and few more applications. We have a rpm based build system similar to fedora.
...
2
votes
3
answers
569
views
Use of special characters in filename
I need to create a file named *'test'*
If I write touch \'test\'
ls shows 'test'
But if I write touch \*\'test\'\*
ls now shows *'\''test'\''*
What's the trick ? Can someone explain me what I did ...
1
vote
1
answer
272
views
"ls" sees different files in the same folder on the same machine in two different terminals. How is this even possible?
A very strange situation occurred to me just now. I'm managing some stuff on a cloud VM running Ubuntu over SSH in a TMUX session. Right now, I have two panes open, which see different files even ...
-1
votes
2
answers
2k
views
ls command adding quotes in bash script
I have a folder named folder1 with directories test.mp3 and test.mp4.
I have a bash script that looks like this
ORIGINATION_PATH=folder1
ext=mp*
files=($(ls "$ORIGINATION_PATH"/test/$ext))
...
0
votes
0
answers
25
views
ls long listing column "number of hard links": What does that mean? [duplicate]
Please shed some light on that erratic, second column of ls -l, that numeric column between the 1st one - the permission string - and the third one - the user ownership.
I just can't pin it down, what ...
0
votes
2
answers
46
views
Counting Files in Remote location using sftp in shell script
Getting Error with the below command to check on the Remote directory a specific type of files. The requirement is to get the count of the specific files.
file_exists=$(sftp $FTP_UNAME@$FTP_HOST ls *$...
1
vote
1
answer
2k
views
LS_COLORS not respected on Cygwin
Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an ...
71
votes
5
answers
58k
views
What is the difference between `ls` and `l`? [duplicate]
I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is ...
1
vote
0
answers
61
views
Recovering "invisible" files from external HDD
My external HDD (WD Elements) just went into a strange state and I am asking this question to see if anyone can make sense of this.
I was running a long job overnight which reads some large files from ...
34
votes
1
answer
15k
views
Why are reboot, shutdown and poweroff symlinks to systemctl?
In Arch Linux, if I do ls -l in /sbin, I can see that reboot, shutdown and poweroff are all symlinks to /usr/bin/systemctl. But issuing reboot, shutdown and systemctl commands obviously does not all ...
0
votes
1
answer
2k
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 ...
0
votes
3
answers
2k
views
How to find last n newest files for each of multiple directories
I am trying to find a ways how to find last n newest files for multiple directories.
The problem with that is that the directories are structured, but not really hierarchical placed, but they have ...
3
votes
3
answers
2k
views
Full file date (without GNU utilities)
I am trying to obtain the full date (created or modified) of a particular file for passing to another program. I have tried variations of options with the ls command but none provide a full date for ...
1
vote
2
answers
526
views
Is there a way to add a "description" field / meta-data that could viewed in ls output (or an alternative to ls)?
I have been using unix systems the majority of my life. I often find myself teaching others about them. I get a lot of questions like "what is the /etc folder for?" from students, and ...
0
votes
1
answer
71
views
How to list matching files to a glob pattern?
I've read, and tried, various answers to a question similar to this but they don't work (or at least I can't get them to) for my particular use case.
I have a CI build pipeline that allows a glob ...
130
votes
14
answers
226k
views
Linux ls to show only file name, date, and size
How can I use ls on Linux to get a listing of files with only their name, date, and size? I don't need to see the other info such as owner or permissions
Is this possible?
0
votes
2
answers
13k
views
List files in your home directory [duplicate]
Im having trouble figuring out that, if I'm in let say the directory /home/test/test2 but I want to find the number of files in the /home directory, how would I do it.
I know how to do it if it was ...
2
votes
2
answers
1k
views
Using `tree`, how do I output files before subdirectories?
I tried to combine --dirsfirst and -r, but directories still show up on top, only in reverse alphabetical order. It seems like -r is applied first, which is also indicated by the man pages.
Any other ...
0
votes
1
answer
76
views
Linux program to quote filename only when necessary?
Consider having these directories and files:
$ tree /tmp/test
/tmp/test
├── dir
│ ├── file_normal
│ ├── file with "double quote
│ ├── file with 'single quote
│ ├── file with space
│ └── ...
0
votes
2
answers
5k
views
ls: cannot access 'filename': No such file or directory (but file exists)
HFS+ formatted drive connected to an Ubuntu box via a SATA/USB cradle.
No issues are reported for the partition by fsck.hfsplus.
Attempting to run "ls" (or anything else) on the affected files ...
1
vote
2
answers
401
views
combine ls -alt with readlink
I have a directory containing a lot of symbolic links and some huge subdirectories. I want to get a detailed listing, sorted by time, of just the files in the parent directory, but with targets ...
46
votes
6
answers
51k
views
Why does "ls -all" show time for some files but only year for others?
If you issue the ls -all command some files are displayed with the timestamp containing the year without the time and others with the timestamp containing the time but not the year. Why does this ...
0
votes
1
answer
53
views
Display the results in an alphabetical order, independently of their case [duplicate]
I am using ls on MacOS 11.6.1. In the output, the Upper cases are displayed before the lower case. For example, I get the following output:
$ ls
Blabla.txt
GAGAS.txt
asdf.txt
blabla.txt
and would ...
4
votes
2
answers
176
views
Why is ls sorting Chinese filenames by length?
I've run into a bit of a weird behaviour that I don't fully understand with ls and Chinese filenames. I'm running macOS 13.6.1 with SIP enabled (no core OS modifications), MacPorts installed, and US ...
4
votes
6
answers
1k
views
Is there any elegant way to find only symbolic links pointing to directories, not other files?
find -type l and ls -l | grep '^l' show symbolic links but do not distinguish between symlinks pointing to directories and those pointing to files. A very kludgy way to do something like this is find -...
16
votes
5
answers
9k
views
Find directories that do not contain subdirectories
I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories.
I know that I could use ls -alR and recursively parse ...
32
votes
10
answers
109k
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
1
answer
175
views
Solve ugly color in ls command
I installed zsh + oh-my-zsh in an archlinux environment.
after that ls command's output became like this:
How I can change folders' color ?
2
votes
1
answer
283
views
"ls" counterpart to "find" operator "-printf"?
The find command has a handy -printf operator that prints
user-specified metadata for each found file/folder. Is there such an
option for the ls command?
As an alternative, I can feed the list of ...
4
votes
4
answers
2k
views
Find largest files in a directory - Taking lot of time
I'm trying to find the top 10 big files from a directory which has lot of sub directories and N number of files. My find command is running forever as its listing all the files and then gets in to ...
267
votes
10
answers
67k
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 ...