Questions tagged [ls]

The command to list the contents of a folder/directory in Unix and Unix-like systems.

Filter by
Sorted by
Tagged with
1 vote
1 answer
94 views

Powershell shortcut to list all files and folders (including hidden files) and order them by date

I'm basically looking for something like ls -alt, but in Powershell (Windows 11). Currently I'm using gci -fo | sort LastWriteTime -Descending but it's a bit of a doozy, and definitely not easy to ...
19 votes
7 answers
31k views

Run an ls without getting the full path

I want a simple list of files in a directory that is not my current directory. I run ls /other/directory/*.txt and get: /other/directory/file1.txt /other/directory/file2.txt I want: file1.txt ...
3 votes
1 answer
4k views

ConEmu + ls -- 256 colors not working

I'm using ConEmu (specifically Cmder's version). Running 'cmd', it supports 256 colors (top). However, I can't get other programs to run in 256 color mode. I've tried Perl (middle) and ls (bottom), ...
1732 votes
10 answers
1.5m views

How can I sort the output of 'ls' by last modified date?

How can I sort the output of ls by last modified date?
0 votes
2 answers
4k views

Can't run the ls command on the root directory without using sudo

CentOS 7.6.180 GNOME-CLASSIC 3.28.2 I've always been able to run ls on the / directory in the system above. Now it just hangs when I run ls. Same if I try to see the / dir with software other than ...
7 votes
3 answers
21k views

'ls' command very slow

I have about 17k files in a directory. When I run ls directory, I have to wait for about 15-20 seconds before the results are displayed. On the other hand, when I run ls directory | wc -l or ls ...
0 votes
0 answers
1k views

ls to list directories sorted by date in timestamp AND by date in filename appendix results in little satisfaction

For listing of directories I always use commands like ls -la --time-style=long-iso <directoryname> And all is at best. Yet on some cases I append a date-time suffix to the filename. This is ...
7 votes
2 answers
2k views

Is there a straightforward way to color ls output according to Finder label colors in macOS?

I have a client with a directory tree that has a number of high-level directories that I need to have on my local development machine. I rarely look at them unless something goes awry. I've marked ...
1 vote
1 answer
39 views

The Ranger file manager for Linux hangs with just "loading...ranger"

When I run Ranger, it prints its standard message: loading...ranger But then hangs forever. What is the root cause?
0 votes
1 answer
53 views

ls with range name of file

I have files with numeric as it's file name. 10asdfsfl.txt 11sdfkf.txt 20sdfdf.txt 22sdfdf.txt 30saadf.txt 40asdfdf.txt 51sadfsf.txt 62ddgfg.txt if I use ls -l [40-50]* it returning list of files ...
18 votes
9 answers
41k views

How to produce a Linux-like `ls` output in Powershell?

I don't want the output of ls(Get-ChildItem) to be vertical (one file one line) in Powershell. I want it to be horizontal (like a table in Linux). After searching the web I don't know how to do that. ...
3 votes
0 answers
72 views

hiding files with Windows "hidden" attribute in msys2 "ls"

I'm running msys2 on Windows 11: $ uname -a MINGW64_NT-10.0-22621 couch-potato 3.4.9.x86_64 2023-09-15 12:15 UTC x86_64 Msys And I have it configured to use my Windows home directory (/c/Users/<...
0 votes
1 answer
45 views

How to understand the hardlinks field of a directory

I've run ls -l command but I have got a big confusion: Ouput of ls -l in home directory: $ ls -l total 16 drwxr-x--- 19 farah farah 4096 اگست 18 18:40 farah drwxr-x--- 40 hussain hussain 4096 ...
-3 votes
2 answers
600 views

ls -R instead of find

I can see ls -R lists all files and folders. I can grep the file name from the list. What are the advantages of "find" ? Also, any caveats if I use ls -R instead of find?
6 votes
3 answers
7k views

How come the ls command prints in multiple columns on tty but only one column everywhere else?

Even after using Unix-like OSes for a couple years, this behaviour still baffles me. When I use the ls command in a directory that has lots of files, the output is usually nicely formatted into ...
0 votes
1 answer
122 views

ls ignoring extensions when colorizing with LS_COLORS

I'm trying to set LS_COLORS to colorize my ls output, but for some reason it is ignoring any file match patterns. It is correctly coloring executables, directories, etc., but it seems to be ...
1 vote
1 answer
73 views

Difficulty performing complex sorting when listing files in a directory with the ls command

The behavior I'm seeking is a nested sort with the ls command where sorting by one method doesn't cancel out sorting by a second method. The exact desired behavior is essentially: First sort with ...
2 votes
2 answers
4k views

Why ls -l total is 0 even even there are files in the directory?

I have a directory, inside that, I have created 2 files and have written some content in these files when I run ls -l. It still displays the total as 0. Why? It should return some positive integer. I ...
0 votes
1 answer
264 views

Why UNIX socket files end with and equal sign in ls?

When I list (ls) files in directory, I see the equal sign = after some files. All these files in my case are UNIX domain socket files: user@Debian11:~/src/unix_sock$ l a.out* cli_stream* ...
3 votes
2 answers
1k views

how to make ls show hidden files then directories then regular files in order

Is there a way to get ls to show all dot files including hidden directories first then regular directories then regular files? I have read throughout the ls man page but come up with nothing. I have ...
5 votes
2 answers
979 views

How to list only tar files

I have a silly problem usr01@srvlnx01:~$ sudo ls /var/opt/gitlab/backups/ 1685014011_2023_05_25_13.2.3_gitlab_backup.tar 1685016443_2023_05_25_13.2.3_gitlab_backup.tar tmp but usr01@srvlnx01:~$ ...
3 votes
1 answer
10k views

How to create a fixed size virtual disk with qemu-img?

What's the best way to create a fixed size disk with qemu-img ? I tried doing this., and it always seems to be creating a virtual /growing disk, doing a ls returns the actual small size of the vmdk. ...
8 votes
3 answers
15k views

How do I `cd` and then* `ls` automatically in linux?

I have found myself keep doing cd some_dir quickly followed by ls for quite some time now, and have been trying to write a bash alias to let me do this, such as: alas cd="cd $@; ls"; Problem with ...
1 vote
0 answers
258 views

What is the difference between different options for 'ls' colored output in zsh?

I want to display colored output for the 'ls' command in the terminal for my MAC but I do not understand the differences between some of the methods. On some articles and reddit posts I saw people ...
1 vote
3 answers
2k views

How do I recursively list the contents of all files in a repository (extension-agnostic) into a single text file?

I know that using "ls -R ." in bash you can recursively list the filenames. Can I use some similar command to list the contents of each file just the way their names are displayed using the ls ...
5 votes
6 answers
12k views

Alternatives to cd/ls for command line navigation?

I generally work a fair amount from the command line in order to launch vim, git, ssh and so on. However, I find the Finder's columnar view more natural for browsing through my files. Unfortunately, ...
285 votes
6 answers
315k views

How to have Linux ls command show second in time stamp

Something annoying about ls -l command is it shows only hour and minute for a file(like 08:30). How can I see the second portion(like 08:30:44)? man 1 ls and search for 'second' does not give any ...
1 vote
0 answers
161 views

set colored-stats ignores $LS_COLORS

Problem I am trying to make auto-completed files be colored according to $LS_COLORS in bash. But autocompletion ignores my $LS_COLORS variable and gets color values from some-place else. Setting I ...
13 votes
3 answers
5k views

How to physically reorder files `03.mp3 01.mp3 02.mp3` (`ls -f`) in a directory?

The physical order of the files matters when I copy them onto my USB stick and listen in car mp3 player. Most of my music album folders are unsorted, e.g. ls -f may produce: 03.song3.mp3 01.song1.mp3 ...
0 votes
1 answer
1k views

file hyperlink not working under tmux

When using tmux hyperlink feature does not work. For example: ls --hyperlink *.pdf list .pdf files and provide a link to click and open when using under terminal emulator, but fails when using tmux. ...
8 votes
6 answers
30k views

Get the last file name in a variable in bash?

In a directory, I have the following files: myfile_v01.txt myfile_v02.txt myfile_v03.txt How to make a bash script that detects the value of the last version and put the filename of this last ...
39 votes
4 answers
35k views

How to diff file names in two directories (without writing to intermediate files)?

I am trying to do something along the lines of: diff `ls -1a ./dir1` `ls -1a ./dir2` But that doesn't work for obvious reasons. Is there a better way of achieving this (in 1 line), than this? ls -...
102 votes
8 answers
61k views

What does the @ mean on the output of "ls" on OS X' terminal?

When doing an ls in a directory I get the following output: 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
2 answers
5k views

ls linux command: how to filter files in other directories

I know what ls folder/ and ls *abc* do in linux. I want to filter out some files in a specific folder. I tried this: ls folder/ *abc but it does not return correct values. Any idea? Thanks
1 vote
1 answer
180 views

Ubuntu - ls -Z only shows question marks and file names

When I'm using ls -Z /etc I only get question marks and filenames. I don't get anything about the security context. Does anyone know anything about this?
1 vote
1 answer
208 views

Are /var/mail/root and /var/spool/mail/root hardlinks for the same inode?

Just found out this: # diff /var/mail/root /var/spool/mail/root # (nothing) # ls -i /var/mail/root /var/spool/mail/root 1284 /var/mail/root 1284 /var/spool/mail/root Same content, same 1284 inode ...
4 votes
2 answers
816 views

How do I change the color of binaries listed by 'ls'?

In Mac OS X, when I do ls the binary files have red color, how change this color to green? Similar to other Unix.
0 votes
2 answers
880 views

Why does `ls 'C:\$Recycle.Bin\'` show nothing?

I have a lot of files in Recycle Bin, yet using either ls 'C:\$Recycle.Bin\' or Get-ChildItem 'C:\$Recycle.Bin\' in PowerShell 7.1.5 there is no result. Do you know why?
66 votes
8 answers
26k views

How can I make "ls" show dotfiles first?

Somewhere along the way I screwed up my ls command and now I get this ordering when running $ ls -AhHl --color=auto -rwxr-xr-x 1 clang clang 640 Mar 1 02:46 apple-touch-icon-precomposed.png -rwxr-...
18 votes
5 answers
16k views

How to list files recursively and sort them by modification time?

How do I list all files under a directory recursively and sort the output by modification time? I normally use ls -lhtc but it doesn't find all files recursively. I am using Linux and Mac. ls -l on ...
0 votes
1 answer
456 views

With `ls -sh` is 1K a kilobyte, a kilobit, 1000 bytes, 1024 bytes, or what?

Preface to my question (this isn't my question): I've been looking for a command-line tool to that tells me how many bytes, kilobytes, megabytes, gigabytes, etc. that a file is (not some other form of ...
102 votes
4 answers
63k views

Icon? file on OS X desktop

When I ls my Desktop from terminal (by using ls ~/Desktop), I see a file named Icon?. As far as I can tell, it's empty (nano Icon? shows nothing). It doesn't show up on my actual Desktop, and open ...
1 vote
1 answer
545 views

Can you underline directories in zsh with ls?

I would like to underline directories when I do ls. Is this possible in a default Mac terminal and zsh? Or do I need something like iTerm2 + ohmyzsh. From what I found LSCOLORS doesn't support ...
7 votes
4 answers
3k views

Ignore NTUSER.DAT files when ls on Git Bash?

I use Git Bash as my terminal on Windows. When I ls in my Home directory, I see some NTUSER.DAT entries, which I assume are system files. They don't appear when I run dir in the default Windows Prompt....
0 votes
1 answer
948 views

How can I watch a folder on an sftp server for new files?

I log in to a sftp server, and to see the files I type ls. Is there any way to recursively watch a folder? For now I just keep typing ls -tlh. Is there a way for that to happen without me typing it? ...
80 votes
9 answers
69k views

How do I get ls --color=auto to work on Mac OS X?

I'm trying to move my bash configuration from Ubuntu to Mac OS X and it looks like ls is slightly different. For instance, it won't accept the --color option. How do I get this to work?
0 votes
1 answer
695 views

How to refresh terminal after function call

I've written a simple function to search the current folder when I press ctrl+f with exa and peco, after I choose a directory I want to cd into it. (ll is modified version of ls) pecofunc() { ll | ...
0 votes
1 answer
45 views

How to restrict a user from seeing hierarchy of files?

Is it possible to restrict a user from seeing hierarchy of files? The user shouldn't be able to see the hierarchy of files with ls or any other commands.
0 votes
0 answers
181 views

How to ls files with output starting on a specific letter?

I want to ls all files from /bin that starts with letter s, and this is the furthest I could think, but it does not print out information: ls /bin | grep ^s Does anyone have a hint?
0 votes
1 answer
230 views

Folder that is not hidden does not appear in `ls`, autocomplete or Finder

I have a folder ~/Library/Application Support/minecraft that does not appear at all in ls, autocomplete or Finder. If I navigate to the directory in the terminal and use open ., Finder opens up to the ...

1
2 3 4 5
7