Questions tagged [ls]
The ls command lists the contents of a directory.
1,316
questions
0
votes
0
answers
22
views
set colored-stats ignores $LS_COLORS
Problem
Bash autocompletion ignores $LS_COLORS variable and gets color values from someplace else.
Setting
I have a dircolors file and just the following declarations in .bashrc:
eval `dircolors $...
0
votes
2
answers
47
views
how to list all files in a given period according their duration(not moment) of access
under linux, how to list all files
in a given directory and its subdirs,
in a given period, say last 10days,
according their duration of access, ideally the result ought to be sorted by access ...
3
votes
1
answer
370
views
The Linux 'ls' command and directory privileges - "cannot access /tmp/restricted/foo*: No such file or directory"
Why does one command work and the other doesn’t? I have found some remotely related articles, but I failed to understand them.
$ sudo ls -la /tmp/restricted
total 12
drwxr-x---. 2 root root 42 ...
0
votes
0
answers
23
views
find can not find size between A and B [duplicate]
problem description
I was using find(GNU version) to find files with size between 4G - 5G with below command
# find . -size +4G -size -5G -exec ls -1hSs {} +
But below can work
# find . -size +4G -...
1
vote
1
answer
152
views
The "ls" command is only showing a single column
I'm using Windows Terminal to SSH into an Ubuntu virtual machine. When I issue the ls command, the output is a single column, similar to ls -al but without the extra info. I want the output displayed ...
0
votes
1
answer
65
views
test -r contradicts ls -l
I'm struggling with files and directory permissions.
ls -l is telling me something that test -w contradicts.
$ ls -l
total 1792
-rw-r--r-- 1 root www-data 168 Jan 29 23:53 CODE_OF_CONDUCT.md
-rw-...
0
votes
0
answers
28
views
Random timeout on basic operation in bash
Context
I have a GitHub Action running on a linux machine.
It does the following (might want to skip to problem first as most of this might be irrelevant):
pwd: /home/runner/work/net.twisterrob....
0
votes
0
answers
18
views
LSCOLORS stopped working on macOS after installing GNU core utilities
After installing and making GNU version of the core utilities default in my macOS terminal by adding the following to the path, LSCOLORS stopped working. I am using using bash shell.
export PATH=&...
0
votes
1
answer
54
views
"ls -l" but with output in more than one column? [duplicate]
Monitors tend to be more wide than tall. When there's hundreds of files in a folder, ls -l and ls -l | more will only show you me maybe 100 files at a time, due to the lack of vertical space on the ...
14
votes
2
answers
2k
views
Why does 'ls' only display contents when I'm in a certain directory?
I am facing a very confusing behaviour of ls that I cannot search for. It displays that there are contents in a directory, but only when I'm in the directory where these were created from.
Let me show ...
0
votes
1
answer
25
views
Suppress log on "List folder" command with no directories
Shell: Bash
Reproduction steps:
Make a folder mkdir folder
Change folder cd folder
List directories ls -d */ -A
Read log message ls: cannot access '*/': No such file or directory
Question
How to ...
1
vote
0
answers
26
views
Emacs dired list .(dot) ..(dotdot) first
In short, how do I implement the solution in following question in emacs for use in dired? I cannot comment there, so I started this question.
How can I make “ls” show dotfiles first while staying ...
0
votes
1
answer
52
views
Why isn't `which ls | file` working?
I would like to use the result of which ls and see the file type using file. However, when I type in which ls | file it doesn't work. When I try to do file < which ls, that doesn't work either.
Any ...
1
vote
1
answer
349
views
Remove background color of directory when displaying ls
I have this issue where some directory are colored
I'd like to keep the color but remove the background (here in green but it can be sometimes an other color)
I'd like to remove background colored.
I'...
-3
votes
3
answers
460
views
coreutils ls summary
Why is there no summary option in coreutils ls command, like MS-DOS/Windows has?
With summary option I mean:
count the files and dirs and sum up their sizes.
Update:
It should read: "Even DOS/...
0
votes
0
answers
57
views
ls -alh and du -sh shows difference in size.. why is that?
Why is this size difference ? Can someone explain ?
[root@~] ls -alh /vmfs/volumes/50a4a9e6-13184850/SYD0TXT01/vmware.log
-rw-r--r-- 1 root root 2.1G Nov 25 00:48 /vmfs/volumes/50a4a9e6-...
1
vote
0
answers
22
views
Linux "ls -sh" command error in (corrupt?) folder print outs many blank spaces?
I am working with some disorganized data on a server. For a couple of the folders when I use the command:
ls -sh
To list files and file sizes, the seems to be an error where the cursor starts ...
0
votes
0
answers
36
views
Why is file size in ls -s and ls -l not matching? [duplicate]
Output of ls -lh:
total 228K
-rw-rw-r--. 1 xyz xyz 226K Nov 13 19:42 image-3309091885.jpg
Output of ls -sh:
total 228K
228K image-3309091885.jpg
Is the file size 226K or 228K? I am honestly confused ...
2
votes
1
answer
39
views
Is it possible to list files using ls with du directory size?
I'd like to list all the conterns of a directory (including subdirs) and their real size (including dir sizes). I can list them with ls, and I can see the size of each with du -sh. But is there a way ...
0
votes
0
answers
19
views
Automatically Hide empty folders in Nautilus and/or gnome-terminal without renaming
$ nautilus --version
GNOME nautilus 42.2
$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Is it possible to hide empty folders while browsing in Gnome Nautilus without ...
0
votes
2
answers
60
views
Effect of slash (/) suffixes on symlink names for `ls` with the `-F` option
By way of example, I have a directory structure like this:
$ \ls -F
dir/ lnk@
$ \ls -F dir
FILE
$ \ls -l lnk
lrwxrwxrwx 1 user group d Mon hh:mm lnk -> dir
My ls command is aliased. I am using \...
0
votes
1
answer
81
views
File listed but not present
I am running 64-bit KLV-Airedale (a fork of Void Linux). When I try to do ls /usr/lib64/gio/modules/libgioenvironmentproxy.so, I get-
ls: cannot access '/usr/lib64/gio/modules/libgioenvironmentproxy....
6
votes
1
answer
533
views
How to find directories with 4-symbol unicode characters eg `<0328>`
While backing up my directories, the ones with names containing Polish characters like ę, ą, ż, ź, etc got "duplicated".
When I do ls -al I get response like:
drwxrwxr-x+ 310 root users ...
0
votes
1
answer
73
views
How can you list a directory using the inode not the directory name? I have the same directory name appearing twice with different inodes
When I do a directory listing of a python installation the include directory appears twice and each one has a different inode.
╰─○ ls -i1
2282047 bin
2641630 include
2642559 include
2282048 lib
...
-3
votes
1
answer
2k
views
Getting cannot access permission denied error [closed]
I am getting question marks [?] in the "ls -lrth" output for files. When I try to change permission it gives "cannot access 'filename'" permission denied error.
1
vote
2
answers
75
views
how to prevent ls to recursively list files in a subdir
I have, e.g., in the directory /etc/ files without extension and with extension
/etc/profile
/etc/profile.1
/etc/profile.2
and there is a directory given by the system containig some files:
/etc/...
4
votes
3
answers
762
views
ls command line-wrap prevention
I'm looking for an answer to this question that doesn't involve the less command:
Is there a way to run the ls command in terminal, and prevent line wrapping for long filenames?
For example, upon ...
0
votes
2
answers
168
views
How to get only file names from an ls -la (ll) listing?
I need a long (vertical) list of all file names of all files in a directory.
How to get only file names from an ls -la (ll) listing?
Only the names, not:
drwxr-xr-x 9 USER GROUP 4096 Jul 20 10:30 ...
2
votes
2
answers
96
views
Exclude "empty" folders from ls output when using --ignore
Suppose I have a folder with lots of subfolders and they are only supposed to contain archived files and I want to check that there are no other file types.
I can use the command
ls -l -R /backup --...
4
votes
1
answer
133
views
ls command still reads the default configuration even after setting the LS_COLORS
I know there are several related questions asked about this but I could't solve my problem with those.
Expected behavior:
What I want is to disable all coloring stuff and just make the directories ...
1
vote
0
answers
266
views
ls /sys/class/udc > UDC "ls:write error: Device or resource busy"
ls /sys/class/udc > UDC
"ls:write error: Device or resource busy"
Trying to use my device as an OTG client, but I can't write to the UDC file. lsof returns nothing. Any suggestions ...
0
votes
1
answer
97
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 ...
3
votes
2
answers
235
views
file listing: difference between ls and echo *
on a lustre file system with thousands of file in directories, each time I type ls I get a large delay until files are listed. Same happens with other commands that need file listing. But if I type ...
1
vote
1
answer
47
views
How to do pattern matching on `.bashrc` for file extensions
I'm modifying my .bashrc: I want to make it so that .zip,.tar and .tar.gz files (and maybe more later down the road) are shown with a red color. Thing is, I want to match for all those files once. So ...
1
vote
1
answer
88
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 ...
5
votes
1
answer
891
views
ls: bash: printf: `Y': invalid format character in VS Code, not in Terminal
I upgraded to Linux Mint 21 (based on Ubuntu 22), having number of small issues, one of which is in VS Code, not in Terminal (gnome-terminal), running ls alias:
bash: printf: `Y': invalid format ...
0
votes
0
answers
30
views
How to set file permission to 777 using umask [duplicate]
It is true that i may not have understood how umask calculations work.
This query is just for a test case (my learning).
My intention is that my process should generate a file pdf file1.pdf with full ...
1
vote
2
answers
137
views
How to make a for loop to read directory names with spaces in them?
I need to create a script to scan folders in a directory and take the name of each folder, make a .txt file, name it with the name of the folder and put inside that folder.
For example:
A directory ...
0
votes
1
answer
87
views
for loop parsing of ls and the magic behind *
I know that the following is bad:
for i in `ls -1 *.MOV` ;do ...
and that the proper syntax is
for i in *.MOV ;do ...
But what are the mechanics behind it? I mean, what part of *.MOV tells the ...
-1
votes
3
answers
257
views
ls: long listing format but ignore files starting with dot
The default behaviour of the ls command is to ignore files starting with dot, but if you use the long listing format with -l they will appear. This is inconvenient and counter intuitive for me, I want ...
0
votes
1
answer
54
views
Weird LS output on WSL2
Using ls or exa I get a weird output on windows subsystem for linux :
Can someone point out what's wrong? I have no funny aliases here. Just running ls.
0
votes
0
answers
12
views
How to interpret the output of "ls -lO" flags on OS X? [duplicate]
This answer says you can list the flags of a file on OS X with ls -lO. However, how to interpret the output? Here is an example:
$ ls -ldO Library
drwx------@ 72 foo staff - 2304 Feb 2 20:02 ...
2
votes
1
answer
303
views
Get specific file for every week using ls command
Could someone help me to get the file for every week using ls command?
ls -t {path} | grep -e "-1700" | head -30 | sort -r
With this ls command, I got below mentioned output
2022.05.30-1700
...
5
votes
0
answers
662
views
Ubuntu ls doesn't show all the files, but when I "ls filename", it shows up? [closed]
I am using PHP 7.3 to move some files around, in a larger app.
The PHP 7 is running on Ubuntu 20.04.4 in a wsl2 container in Windows 10.
On reading through other questions, it seems this is probably ...
1
vote
2
answers
225
views
How does ls [[:punct:]]* work?
I am learning bash. Currently, I have a file called _something.txt and when I use:
ls [[:punct:]]*
I get the following error:
ls: invalid option -- 'V'
What am I doing wrong?
0
votes
6
answers
2k
views
How to cut string on last underscore character?
I have list of files like below:
[root@ods1 backup]# ls -l
total 93892810
-rw-r----- 1 root root 651248 Feb 17 08:34 abc_def_g_17-02-2022.sql
-rw------- 1 root root 665248 Mar 23 08:46 bbc_23-03-...
0
votes
1
answer
153
views
how to modify the color of fields of ls -la?
I recently found an example of colored output when using ls:
AFAIK that is on MacOS with the BSD implementation of ls.
I know how I can change the color of the filenames via LS_COLOR, but I would ...
0
votes
2
answers
825
views
meaning of file type c in ls -l command [duplicate]
I am wondering what the type c is in the ls command.
I was following the symlinks at /dev/stdin and ended up with /dev/pts/0
$ ls -l /dev/pts/0
crw--w---- 1 blue tty 136, 0 Apr 8 21:50 /dev/pts/0
I ...
0
votes
0
answers
23
views
Writing filenames into file also saves that filename name into file. How do I get it to stop, reliably? [duplicate]
I'm relatively new to bash. I am learning to work with bash, r, etc., within the realm of bioinformatics.
I'm having the following problem.
I have a list of files. Let's forget that metadata exists ...
2
votes
2
answers
817
views
Sort files by modification date, then by name
Let us assume a directory that contains pictures from different cameras:
DCIM1234.JPG
DCIM1235.JPG
DCIM1236.JPG
DSCN4120.JPG
DSCN4121.JPG
DSCN4122.JPG
DSCN4123.JPG
IMG5840.JPG
IMG5841.JPG
IMG5842....