Questions tagged [ls]

The ls command lists the contents of a directory.

Filter by
Sorted by
Tagged with
5 votes
0 answers
122 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 ...
user avatar
  • 51
-2 votes
0 answers
31 views

How can I make dircolors configuration work in emacs shell?

In emacs shell (opened by M-x shell), I have problem with the coloring of the files listed by ls. I want to change the coloring to dircolors.ansi-dark, so I added TERM dumb to the file dircolors.ansi-...
user avatar
  • 89.8k
0 votes
2 answers
45 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?
user avatar
  • 1
0 votes
6 answers
102 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-...
user avatar
0 votes
1 answer
48 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 ...
user avatar
  • 1,066
0 votes
2 answers
38 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 ...
user avatar
  • 145
0 votes
0 answers
22 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 ...
user avatar
2 votes
2 answers
92 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....
user avatar
-1 votes
1 answer
135 views

dircolor doesn't work

I was using bash's autocompletion by pressing TAB key at the end of a pathname. I was also using ls (alias ls='ls --color=auto' in ~/.bashrc). I had trouble recognizing the filenames in the color. (Is ...
user avatar
  • 89.8k
1 vote
2 answers
580 views

ls -d command only returns `.` eg, and no child directories

I have standard ls installed, I also have lsd installed, which is a nerd-font drop-in replacement for ls. I mention this because the error may have something to do with the alias. For testing right ...
user avatar
  • 27
1 vote
0 answers
36 views

ls displays no files even though folder contains files

This question is actually derived from a problem I have with a python library which deletes a file tree and then recreates the content, but on attempt of execution of a file inside the directory, the ...
user avatar
1 vote
1 answer
29 views

Can ls show read-only files in a specific color?

I like using ls --color=auto and I know how to use dircolors to change the colors of ls's output. I want ls to display read-only files in a color different than "normal" files but don't see ...
user avatar
0 votes
2 answers
62 views

Why I need to `ls -ld` in order to see a hidden directory which `ls -a` is not showing?

I have access to a compute cluster where most of the time I need to run ls -ld /some_dir/my_dir to be able to see and access this directory, otherwise it seems hidden and cannot be seen by ls -a. ...
user avatar
  • 111
2 votes
1 answer
99 views

What naming convention can I use to ensure that file names sort in a consistent order using ls?

I'm trying to come up with a naming convention for a set of files such that they always sort in a consistent order without requiring any special options, but I'm having a difficult time achieving this....
user avatar
  • 474
1 vote
2 answers
39 views

ls -v (natural number sorting) command sorts capitalized files/dirs ahead of non-capitalized files/dirs

I'd like to have natural sorting of numbers, but capitalized files/dirs not sorted at the top. Is that possible? Currently ls -lv produces: FOO/ bar/ ZEBRA.x foo.x foo-1.x foo-2.x foo-10.x I messed ...
user avatar
  • 694
0 votes
1 answer
33 views

Sorting long list of files into multiple sub directories based on name

I have a group of 1000+ files that are labeled using text and date in a folder /home/dir/dir2/oldspot with below format: File taken on 01/07/2020 at 23:08 elevation 5 is aaaaaa-bbbb-cc10dddd-L1-...
user avatar
0 votes
2 answers
128 views

What does "ls * > file1" do?

What does the following command do in Linux? ls * > file1 Does it simply copy all the file names in the current directory into a new file?
user avatar
  • 3
0 votes
2 answers
56 views

Sorting list with pipeline and without ls-lS command

The Linux program ‘sort’ can sort a file, or the output from another program. How do I use sort to sort the output of the ls command by 1) file name 2) file size. I know there are options of the ‘ls’ ...
user avatar
  • 21
1 vote
2 answers
135 views

bash + test if folder is empty but exclude files with a leading dot

We used the following approach in order to verify if a folder is empty: [[ "$(ls -A /var/folder)" ]] && echo "not empty" on /var/folder, we did the following: ls -l /var/...
user avatar
  • 10.9k
0 votes
0 answers
26 views

Why home directory has only one hard link? [duplicate]

I have 9 directories in my home directory but when I am using ls -la command the total hard links showing is 1 (for the home directory). Although there are total 9 directories inside my home directory ...
user avatar
  • 21
2 votes
2 answers
183 views

ls finds files in directory with a specific name, but find does not

I'm trying to find all the files that are inside directories whose names start with 80s. ls 80s*/* finds the correct files, but find . -ipath '80s*/*' returns nothing. What is the correct find command ...
user avatar
3 votes
3 answers
93 views

ls -ls output shows larger number of blocks than the file size

As far as i know the ls command with the "-s" option print the file size in blocks , ls uses the 1024 as block size , but i noticed something weird . For better understanding consider the ...
user avatar
6 votes
3 answers
398 views

Get a list of files (in the way similar to `ls`) on website/webpage before choosing which to download

Let's say I'm on a webpage on which there are several hyperlinks to pdf documents. I want to download those pdf. Is there a way to get a list of those documents (in the ls way) which then allows to ...
user avatar
  • 297
0 votes
2 answers
71 views

How to make "ls -1" to print out in quotation marks in combination with xargs?

I do an ls command like this to list multiple directories. Please be aware of the blank space in the folder X y. ls -1d 2021*/"X y"/foobar Output is '20211121-161518-801/X y/foobar' '...
user avatar
  • 474
0 votes
0 answers
21 views

Compare file attributes between user, group and others

How do i list files in a directory comparing their attributes, if i can not use a regex, e.g. i want to show all files that "user" and "others" have exactly the same rights, or &...
user avatar
7 votes
1 answer
1k views

Why does this new directory have a link count of 3?

$ sudo su # dd if=/dev/zero of=./myext.img bs=1024 count=100 . . . # modprobe loop # losetup --find --show myext.img /dev/loop0 # mkfs -t myext /dev/loop0 . . . # mkdir mnt # mount /dev/loop0 ./mnt # ...
user avatar
  • 173
1 vote
2 answers
59 views

How can I sort du results by time *and* restrict to --max-depth=1

I use rsync to back up my files using --link-dest to sync only differences from the last backup folder. Is there anyway I can see a directory listing ordered by date and restricting it to --max-depth=...
user avatar
  • 253
1 vote
2 answers
68 views

How to sort by the whitespace character

I have this shell script which lists all the names of subdirectories of the current working directory. Is there any way I can sort the names so that directory with whitespaces in the name comes first ...
user avatar
  • 11
1 vote
1 answer
86 views

ls and sort by number for human

I create catalogs mkdir site_{1..44}. I want to sort them site_1 site_2 site_3 site_4 ... site_44 I execute the command ls | sort -h and I have site_1 site_10 site_11 site_12 site_13 site_14 site_15 ...
user avatar
  • 39
0 votes
0 answers
43 views

How to figure out what the first character in the lines of the output of ls -l mean? [duplicate]

crw-r--r-- 1 root root 10, 235 Nov 29 20:11 autofs drwxr-xr-x 2 root root 280 Nov 29 20:11 block crw-rw---- 1 root disk 10, 234 Nov 29 20:11 btrfs-control ...
user avatar
  • 160
0 votes
1 answer
112 views

No such file or directory Error while using find or ls -al in unix directory

I am trying to find reason behind this happening and also a solution . When I try to run below command on Unix directory which has around 16 files and also one of the application process which keeps ...
user avatar
0 votes
2 answers
294 views

Using ls on many files results in error "bash: Argument list too long" [duplicate]

I am trying to populate a txt with all the names of .fits files from a folder with this command: ls *.fits > output_all.txt The number of .fits files in the folder is >330k and I get the error ...
user avatar
  • 139
1 vote
1 answer
64 views

Why does `grep` seem to give slightly different results with a plain `ls` command? [duplicate]

I have a directory with some files - mkdir _tmpmm touch a1 b2 c3 d4 ls # a1 b2 c3 d4 When I grep for a on the output of ls, I see only the file a1 - although the ls output is showing 4 files on ...
user avatar
  • 113
0 votes
2 answers
52 views

keep formatting when piping ls to head

when I call ls in ~ i get Documents Downloads Templates Desktop Music Videos Public Pictures If i pipe ls to head (e.g. ls | head -30) i get Desktop Documents Downloads Music Pictures Public ...
user avatar
  • 103
2 votes
1 answer
272 views

Why is the triple question mark globbing (???) not working with ls?

I am trying to list all files with a name of 3 characters in /usr/bin. ls ??? should do exactly that, but it lists every file in the directory. Note that ls ???? works as intended, showing only the ...
user avatar
  • 31
1 vote
1 answer
73 views

unable to rm/chmod even with sudo

I'm still kind of new to linux, but was already able to solve most of the issues with resources on the web. However there is an issues which I need help with: when ls -al in terminal, there seems to ...
user avatar
0 votes
0 answers
184 views

AWS s3 list only the folder names from the bucket

I have an s3 bucket that contains folders inside it with the date prefixes. For example- bucket_name --> 2021-11-01 --> 2021-11-02 --> 2021-11-03 --> 2021-11-04 ....
user avatar
-1 votes
1 answer
47 views

what is the difference between ls -a and ls -A command

$ ls -a . .cache final .lesshst .pki .sh_history .wget-hsts .. .config .gnome .local .presage ...
user avatar
0 votes
1 answer
330 views

What does the output `d?????????` in `ls -l` mean? [duplicate]

What is the situation why ls -l returns a list of subdirectories in the form below? d????????? ? ? ? ? ? Subdirectory A tree launched on that directory returns 0 directories, 0 files for ...
user avatar
0 votes
1 answer
637 views

How to list all files and get the total size of all files in an sftp server?

I am connected to an sftp server using sftp -i key.pem user@server The server contains logs and I can list logs up to 4 days old using ls. The problem is that ls does not seem to be able to fetch ...
user avatar
0 votes
1 answer
53 views

What determines how files are ordered when using ls without sort?

The order when using ls with -U flag is the same order that I get when using dirent.h library in C and display file names in a loop. When I display d_off member of the dirent struct the numbers appear ...
user avatar
  • 3
3 votes
1 answer
55 views

Sorting ls output respecting locale but not ignoring nonalphanumeric characters

Let's say I have a directory with the files _b, a, c, č, d. I would like to sort the files according to the cs_CZ.UTF8 locale but without ignoring the underscore, ie like this: _b a c č d. Currently, ...
user avatar
2 votes
1 answer
496 views

bash, how to manipulate 'ls' around some limitations? [closed]

ls seems to have a number of limitations that seem odd to me that are not included in its switches (such as --max-depth= as other tools have). I like to maintain common standards (so ls and ll follow ...
user avatar
  • 559
-6 votes
2 answers
61 views

How do you print out repeated lines according to my problems below? [closed]

Below are the questions that I'm having trouble with, I only know how to redirect the stdout of ls to the foobar file on question 1: ls > foobar Write a command line to redirect stdout of the ...
user avatar
  • 1
0 votes
1 answer
122 views

Error when running ls "exa: error while loading shared libraries: libgit2.so.1.1: cannot open shared object file: No such file or directory"

I'm running Manjaro Linux and upon running the ls command or any variation of it with flags I get the error: exa: error while loading shared libraries: libgit2.so.1.1: cannot open shared object file: ...
user avatar
  • 15
0 votes
1 answer
90 views

I don't understand how "ls" command works [duplicate]

I wanted to check what is the size of pg_backup folder, so I used this command: [postgres@server02 ~]$ pwd /var/lib/pgsql [postgres@server02 ~]$ ls -lh total 4.0K drwxr-x---. 7 postgres postgres 86 ...
user avatar
  • 143
1 vote
1 answer
66 views

ls -F: where is the official Unix/Linux complete list of the indicator entries types?

About ls -F in the man ls for -F does mention about: -F, --classify append indicator (one of */=>@|) to entries I read the following: What do the symbols displayed by ls -F mean? 14. How to ...
user avatar
0 votes
1 answer
45 views

How to open the n most recently modified files in less/vim?

How can I open all and only the n (e.g. 5) most recently modified files in a directory in less or vim? I know I can use ls -t to sort the output from most recent to oldest. So my intuition would be to ...
user avatar
1 vote
0 answers
81 views

Argument list too long while generating txt file which includes file names in a directory [closed]

I am trying to write all of the file names in the directory into txt file. I used the command, ls /path/of/directory/ > file_name_list.txt But it gives error ls: cannot open directory /path/of/...
user avatar
1 vote
2 answers
389 views

All directories are blue on green on WSL

According to all I've read LS_COLORS with di=01;34 should mean bold blue. No matter what setting I try I cannot get anything except white on black (I assume when my setting is incorrect) or this ugly, ...
user avatar
  • 315

1
2 3 4 5
26