Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [ls]

The ls command lists the contents of a directory.

Filter by
Sorted by
Tagged with
0 votes
1 answer
76 views

Explain the output for "ls -ltr *s*" in ubuntu 22.04

I am new to Ubuntu and was trying to write some commands on my own. I found that ls -ltr * is a wild card, using ls -ltr *.txt will show all files having extension of .txt. Whereas, ls -ltr ex* will ...
kNN's user avatar
  • 11
-1 votes
0 answers
46 views

How to feed lines to a command as complete strings [duplicate]

A directory containing files with spaces $ ls . 'File A' 'File B' 'File C' $ walk . . ./File A ./File B ./File C ls interprets each space as a new file $ ls -ld $(walk .) ls: cannot access './File'...
Gooberpatrol66's user avatar
0 votes
2 answers
58 views

Find files created after a particular time in csh on SunOS

On my SunOS system, I'm trying to find all files created after 7 PM using csh, ls, and awk. ls -l "${Source_files_Dir}"/*.zip| awk -v today="$(date "+%b %d")" '{ date=$6&...
Aravind's user avatar
  • 1,619
0 votes
0 answers
21 views

Non-column output of `ls` piped to `sed` [duplicate]

As far as I know, command sed precesses its input line by line. Thus, the following command successfully outputs only the directories in the current directory: $ ls -p -1 | sed -n '/\/$/p' Here ...
gambarimas87's user avatar
1 vote
2 answers
92 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 ...
TrisT's user avatar
  • 121
5 votes
1 answer
449 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 ...
yossi-matkal's user avatar
0 votes
2 answers
51 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 ...
yossi-matkal's user avatar
0 votes
0 answers
55 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 ...
elbarna's user avatar
  • 12.7k
2 votes
1 answer
146 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 ...
Logan Kitchen's user avatar
0 votes
0 answers
35 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 ...
jsx97's user avatar
  • 481
1 vote
0 answers
47 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) ...
jsx97's user avatar
  • 481
3 votes
3 answers
223 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 ...
Manuel Jordan's user avatar
3 votes
1 answer
100 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 ...
Dhénin Jean-Jacques's user avatar
0 votes
1 answer
78 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 ...
Evert's user avatar
  • 111
0 votes
0 answers
74 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. ...
Prajval Badiger's user avatar
2 votes
3 answers
576 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 ...
Shoopi's user avatar
  • 31
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 ...
futurewave's user avatar
0 votes
2 answers
63 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 *$...
MALABIKA GARAI's user avatar
1 vote
0 answers
63 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 ...
mRcSchwering's user avatar
0 votes
1 answer
76 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 ...
Kepboy's user avatar
  • 101
0 votes
1 answer
80 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 │   └── ...
midnite's user avatar
  • 443
0 votes
1 answer
54 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 ...
ecjb's user avatar
  • 403
4 votes
2 answers
184 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 ...
nneonneo's user avatar
  • 1,108
1 vote
1 answer
228 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 ?
mohali's user avatar
  • 13
2 votes
1 answer
286 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 ...
user2153235's user avatar
-1 votes
1 answer
76 views

COMMAND=list in /var/log/auth.log... does list refer to the ls command?

Basically the title. I've been looking through the authentication logs of a compromised virtual machine (it's just a simulation), and I noticed that after the system accepted the hacker's password, ...
Alexandra's user avatar
  • 111
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 -...
Adam J. Kessel's user avatar
2 votes
1 answer
416 views

Get total Git LFS size

How can I get total size of Git LFS files? I can get a listing of LFS files with git lfs ls-files --size: b1d5dd29dd - file1.zip (1.42 GB) 27d3073f43 - file2.zip (120 MB) cacd6dbfe3 - folder/file3.zip ...
wjwrpoyob's user avatar
  • 440
0 votes
1 answer
107 views

Need help with ls and escape characters [duplicate]

I'm trying to create a bash script to run the ffmpeg command on every file in a directory with filenames that contain spaces. This is the script that I started with to do an individual file which ...
Maxhawk's user avatar
0 votes
1 answer
51 views

linux ls -l ACL +, . , gap How to make gap

drwxr-xr-x+ 4 root root 4096 Sep 21 04:00 test << + drwxrwxrwt. 10 root root 250 Sep 21 04:03 tmp drwxr-xr-x. 12 root root 144 Sep 19 03:42 usr << . drwxr-xr-x. 20 root ...
박용원's user avatar
0 votes
2 answers
120 views

Listing filenames with special characters

I have a zsh shell (with oh-my-zsh default config). Why I ls filenames with special characters, they are printed as: ''$'\316\262''=0.35-L=32-m=10.jld2' This should be: β=0.35-L=32-m=10.jld2 but the ...
a06e's user avatar
  • 1,737
0 votes
1 answer
55 views

Any operations with file system takes forever

I'm using Ubuntu 22.04 LTS. Unexpectedly for me all operations with the file system stopped working. I tried ls /, df and nautilus - all of this command takes forever to execute. What happened to my ...
Minuta18's user avatar
1 vote
2 answers
49 views

Write catalogue file names in to a file with additional string at the beginning end of a specific name

In specific directory using ls | tee -a file.txt gives me a list from this directory. Example: file1.txt file2.txt file3.txt How to add specific strings inside ls command into final output simply ...
Adam's user avatar
  • 13
-1 votes
1 answer
69 views

creating hard links Linux question [duplicate]

From the book The Linux Command Line by William Shotts, page 33: So now we have four instances of the file fun. Let's take a look at our playground directory. [me@linuxbox playground]$ ls -1 total 16 ...
Guilherme Woolley's user avatar
0 votes
1 answer
72 views

Linux command line Long List Field question

The Linux Command Line Wiillian Shotts Page 16 Field -rw-r-—r—- Meaning Access rights to the file. The first character indicates the type of file. Among the different types, a leading dash means a ...
Guilherme Woolley's user avatar
0 votes
2 answers
86 views

Stuck at finding the most recent file from a list of directories

I want to find a list of directories, then search for a given file inside them, then choose the most recent one. This is what I try: find /Temp -type d -name Ast 2>/dev/null | while read Dir; do ...
Saeed Neamati's user avatar
6 votes
1 answer
2k views

Why does `ls` in Linux and macOS show different owners (uid) for the same file?

I copied some files to HFS+, using macOS, ensuring that it was copied exactly. On macOS these copied files have 501 as owner according to ls -han. I then plug in the HFS+ usb stick into Ubuntu, and ...
Andreas's user avatar
  • 511
3 votes
1 answer
316 views

How does `ls` find hard links?

Setup The following sequence of commands is setup for my question. root@cd330f76096d:/# cd root@cd330f76096d:~# ls root@cd330f76096d:~# mkdir -p my_dir/my_subdir root@cd330f76096d:~# ls -...
Sweet Shell O'Mine's user avatar
4 votes
2 answers
1k views

How do I reliably capture the output of `ls` in this script?

The following script, play_movie.sh is meant to automatically select a movie if there is only one in the current directory and play it with ffplay. Otherwise it is meant to display a selection of ...
John Smith's user avatar
0 votes
0 answers
23 views

Sum of all file sizes in a folder down not adds up to what what ls or du show [duplicate]

I have downloaded couple of thousands file form a cloud. the download is done without any error. When I check the files occupied space in my hard drive is showing size, then what is shown on the cloud ...
Ahmad.S's user avatar
  • 101
25 votes
3 answers
5k views

Is it now safe to parse the output of GNU ls?

The accepted wisdom for the past few decades has been that it is never a good idea to parse the output of ls ([1],[2]). For example, if I want to save a file's modification date along with its name ...
terdon's user avatar
  • 243k
1 vote
3 answers
67 views

ls starting at particular file

How do I ls files in a directory beginning with a particular filename? For example, if my CWD has these files: $ ls -1 alpha.mp3 bar.xls file1.txt file2.txt foo.odt testing3.txt How do I print out ...
Geremia's user avatar
  • 1,183
0 votes
0 answers
29 views

du and du -h give different results, and neither match ls -lh [duplicate]

I can paste a screenshot if preferred, but here is what I typed: me@server:~/dutest/test2$ du 12 . me@server:~/dutest/test2$ du -h 12K . me@server:~/dutest/test2$ du -b 4243 . me@server:~/dutest/...
Ben Holness's user avatar
-1 votes
1 answer
230 views

What is the "l" command in Linux?

I just accidentally typed l and hit enter. Then this happened. I'm not talking about ls -l just l. Why did this happen?
lunix's user avatar
  • 129
1 vote
0 answers
51 views

Can't list folder on USB connected drive but it's there!

When I run ls /run/user/1000/gvfs/mtp:host=OPPO_SM6375-QRD__SN%3AD5F9F680_d5f9f680/ The following is returned 'Internal shared storage' 'SD card' When I run ls /run/user/1000/gvfs/mtp:host=...
Praful's user avatar
  • 11
0 votes
0 answers
236 views

ls: cannot access pul: Stale file handle

I'm trying to cd into directory pul, but I keep getting the error ls: cannot access pul: Stale file handle This is occurring on a remote work server that I am ssh'ing into, and I've never had issues ...
anonuser01's user avatar
0 votes
1 answer
177 views

Effect of dircolors

What does dircolors affect. Is it for the ls command only ? Should dircolors be called before defining alias ls='ls --color'?
Vera's user avatar
  • 1
5 votes
4 answers
695 views

Copy the n-largest files from a certain directory to the current one

I am trying to copy five largest files from a certain directory to my pwd. Using cp specific/directory$(ls -S specific/directory | head -n) ./ copies the first file and then proceeds to produce cannot ...
Sudoh's user avatar
  • 257
0 votes
1 answer
102 views

ls -F/--classify marks every file as an executable

ls -F classifies ALL files on my mounted partitions as an executable (it appends an asterisk to the end of the file name). The same command performs correctly in other places like my home folder, so I ...
what the's user avatar
  • 113
5 votes
2 answers
1k views

touch command not able to create file in write-permitted directory

This is my user $ id uid=1000(pzk) gid=1000(pzk) groups=1000(pzk) This is my directory structure $ ls -tlrh total 12K d-w--w--w- 2 root root 4.0K Apr 13 10:53 write-for-everyone dr--r--r-- 2 root ...
pzk's user avatar
  • 117

1
2 3 4 5
28