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
0
votes
1answer
37 views

Why find is giving inaccurate responses for 1M and 1G size?

Why find is giving inaccurate/weird responses when I try to look for files that are 1 megabyte size or 1 gigabyte size ? Or even less than 1 megabyte or 1 gigabyte. [root@server1 ~]# ls -lh total 7.8M ...
0
votes
1answer
33 views

What is a purple file from the LS command?

I am working on a c++ project and had a failed compilation (normal kind of errors). When I ran ls (a bit of a habit), it showed a file with a seemingly random sequence of characters: '!4'$'\377\377\...
1
vote
1answer
52 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 ...
2
votes
2answers
87 views

How do I change the color ls in the console for files if group owner is `root`?

I am inside a mounted folder: /mnt/hgfs because of this all the files' owner is root. In this folder when I do ls color for all the files show up as green and for all the folders, there is green ...
0
votes
2answers
182 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 ...
1
vote
1answer
12 views

Trying to copy files with multi-patterns from directory to another directory?

I am trying to copy all files that start with specific pattern from directory to another directory I tried using the command below, cp 8405T* 1208T* 1783T* 6321T* 9269T* 479T* 1743T* 6527T* 6153T* ...
0
votes
0answers
66 views

Linux - What should I consider as Disk Space Usage (apparent size, or something else)?

I have a directory called /tmp/kafka-logs which I can see using ncdu or du command to find out my disk space usage. I am using Fedora Doplphin GUI browser on my laptop. When I see using my GUI file ...
0
votes
1answer
380 views

ls doesn't work in mobaxterm local terminal

I'm having a strange issue running mobaxterm v20.2 on Windows 10: I am unable to use ls to see the contents of the local directory. For example, in this screenshot, the output of ls is empty, but the ...
2
votes
1answer
129 views

Pipe the output of “ls -G1” to “sed” while retaining output colors in macOS

When using the terminal in macOS I created an alias in ~/.bash_profile that lets me list folders and files in one column and with color using the -G1 option like this: something = "ls -G1" This work ...
0
votes
1answer
99 views

Long listing format ls command [special character file data]

When using the ls -l command files that are not Character special file (c) or Block special file (b) before the last modification date they have just one number; the file size. Those 2, have 2 number ...
0
votes
2answers
142 views

List only files for current user

How can I limit ls to only show files where I am the owner? I might be able to string together something using find along with ls, but I'm looking for an ls only solution.
2
votes
1answer
100 views

How to ls --group-directories-last?

The question is basically the same of this post, however there are 2 things that I don't like in the accepted answer: it breaks the natural column structure of ls; tac inverts the order of the output ...
2
votes
2answers
2k views

Bash Script to delete oldest files but keep latest files including sub-directories

I'm trying to delete old files but should keep latest 3 days log files.i tried below command, ls -tr /home/httpd/htdocs/pathname/pathname/config//build/logs/apps/.log | tail -n +4 | xargs rm -- but ...
34
votes
1answer
5k views

Why does the `ls` command sort files like this?

As I was trying to reverse engineer the ls command, I came upon an interesting behavior. When I make 3 files, foo.png, foopa.png, and fooqa.png, ls sorts them as foopa.png, foo.png, and fooqa.png. I ...
0
votes
1answer
2k views

Use awk command to output of ls command

I have a e-book directory that has following format: <authorname> <authorsurname> - <bookname> I want to separate the books by authors. I use the below command in a for-loop for ...
0
votes
1answer
95 views

How to align the columns of ls command output in Xubuntu 16.04.6?

I have this function in .bashrc : { ls -lhNGhgF --color=always --group-directories-first --time-style="+%d-%b-%Y $newline%H:%M" | awk ' { $3 ="\033[1;31m" $3 "\033[0m"...
2
votes
1answer
72 views

Why an empty directory has large volume?

All the directories below are empty [user@xxxx ~]$ ls -lah /home/1m total 387M drwxr-xr-x 22 foo foo 4.0K Apr 17 22:49 . drwxr-xr-x 10 foo foo 4.0K Apr 17 22:49 .. drwxr-xr-x 2 foo foo 9.2M Apr 17 ...
3
votes
2answers
4k views

Run `ls` recursively with wildcards

I'm trying to find all the project files of a particular file type with: ls -ltR *.mb I know there are the files I want in several folders, but I get no results back. What did I do wrong?
0
votes
4answers
62 views

Enumerate files *.pdf exclude *_book.pdf

How can enumerate all file file in dir, exclude by pattern. For example: all *.pdf exclude *_book.pdf. I try so: for $PDF in $(ls *.pdf | grep -v *_book.pdf); do echo "File $PDF" done It is a ...
0
votes
1answer
1k views

dir / ls not displaying files outside of root directory in Windows 10

I've been trying to point to files and directories via my command line or powershell in windows, but for whatever reason the dir or ls command will not display files or folders within the directory ...
2
votes
2answers
156 views

Exclude system entries with “ls” or “find”

Compare Cygwin: $ ls -1 -N /cygdrive/c $Recycle.Bin cygwin64 Documents and Settings pagefile.sys PerfLogs Program Files Program Files (x86) ProgramData Recovery System Volume Information Users ...
0
votes
1answer
26 views

Invisible directory names

When I do ls -l I get the picture below and I have no idea why. I know the names of the directories and I can cd to them no problem but can't see the actual names. How do I fix that?
15
votes
1answer
10k views

Why does ls wrap some filenames in single quotes?

I've noticed that when I do ls in a terminal, some filenames are wrapped in single quotes and some aren't. I don't like the way this looks as I prefer my terminal outputs to be nice and uniform. ...
0
votes
2answers
912 views

What's the difference between these ls command line arguments: -d vs *

What's the difference between ls /example or ls /example/ vs ls -d /example/* Why do they give (almost) the same output?
1
vote
2answers
160 views

How do I show all the files in a directory with a name containing a number?

How do I show all the files in a directory with a name contain a number? I tried ls [0-9] textfiles (textfiles) is my directory. This is how my Linux pocket guide shows me. I am just trying to ...
0
votes
1answer
416 views

Remove the padding spaces in the `ls` result on macOS

When I run command ls on macOS, it shows the folder names with same length, padding spaces for short folder names: jihu@ksm1 Home $ ls bin code devel opt personal shared While on ...
1
vote
0answers
5k views

ls command not working in the home directory

The ls command works fine for me in all other directories except my home directory, where I get the following error: * Exit with code 1, no result found, command line was:?? locate -b -i [\^g]*g[\^a]*...
1
vote
1answer
49 views

Why are files lwith the same time stamp not sorted alphabetically when listed using “ls -lt”?

I read that ls -lt will order files by modification time before sorting by lexicographical order. However, when I use the command with this syntax, I get this result: ls -lt total 192 -rw-r--r-- 1 ...
0
votes
1answer
180 views

Can't show manual pages for `ls` in Vagrant

That's my first question in here and I'm still a beginner so please bear with me. I'm having a Linux Command Line Basics course on Udacity. I got to the point where I'm asked to open a manual page for ...
0
votes
2answers
54 views

Preview current directory in shell

What often happens when I work in a shell - zsh - is that I have cded somewhere and I want to have a quick look at the directory. Using ls may produce a lot of output and leaves it in the terminal. ...
5
votes
3answers
7k 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 ...
1
vote
2answers
413 views

ls -l shows symlinked directory with two trailing slashes

I just copied my ~/.config directory to another and symlinked it back to $HOME. When I run ls -l this shows up like this with the double slash at the end: lrwxrwxrwx 1 lud lud 22 Jul 23 20:25 ...
0
votes
1answer
1k views

'ls' output doesn't show color anymore in macOS High Sierra

I use zsh and oh-my-zsh: As shown in the screenshot ls is not showing color output anymore. I set color theme from iTerm2 and set zsh theme (wezm+ theme) from oh-my-zsh. I try to set manually ...
3
votes
1answer
341 views

find or ls does not list all files in a folder in MacOS (HFS+)

ls or find command do not seem to locate all files located in a specific folder. I'm running a Mac (under El Capitan 10.11.6 (15G21013), 500GB SSD, HFS+). In one of my folders, where I have about 700k ...
1
vote
1answer
26 views

File/directory in the CentOS looks weird

I am connected to CentOS server via PuTTY and I see a weird file/directory in one of the sub-directory which looks unreal. I am not sure how the file exists there and Its not related to our work. Can ...
1
vote
1answer
5k views

'ls' command in terminal is showing all files and file permissions. How do I get back to normal with 'ls' showing only normal files and folders?

Want to get the terminal back to bryce@macbookpro instead of bryce@machine and have the 'ls' command only show visible files and folders.
8
votes
2answers
3k views

How to color output columns of ls?

Title kind of says it all: I would like to get those neat colored columns of the output of something like ls -al, say, as in 10basetom’s answer to this question.
0
votes
1answer
121 views

dot “.” and “..” hidden files taking up space in empty directory

When I ls -ltr on the danny directory, it shows that the quarantine directory size as a little over 2 megabytes. Then I go to the quarantine directory and do an ls, and it has nothing in it - it is ...
0
votes
1answer
686 views

simple way of describing / tagging files in bash

Is there a quick and simple way to tag files in bash so that a list like this one -rw------- 1 root 88039 Sep 29 16:31 7CCE2EC3-3191-4379-C036-1C48CCCE4C6C -rw------- 1 root 1985554 Sep 27 16:09 ...
1
vote
1answer
157 views

How do I get a list of the fullpaths of every .git subfolder in a directory tree?

I am unable to figure out the right set of commands in a Windows Command prompt FOR /? or bash ls to do this. The following batch file I wrote demonstrates what I want, but I would like to know if ...
-3
votes
1answer
406 views

How to create tar file like this?

I need to create a .tar file testDay00. When I run the command ls -1, the output should look like this
0
votes
2answers
3k views

Bash: List files with absolute paths, one per line, no other information

I am looking for a command that lists all files in the current directory. Requirements: Absolute paths One file per line No other information (like size, permissions...) Don't show folders What I ...
2
votes
1answer
196 views

ls(1) acts strangely when input is a variable / subcommand or just typed

D I'm facing a issue on ls(1) that I'm almost sure that it's a silly thing that I'm just letting pass away. Anyways, I can't understand really why this isn't working. I'm using bash for cygwin (Don'...
0
votes
1answer
179 views

How to add a background color to a executable, without replacing the foreground color?

Currently I setting the ~/.dircolors file to: LS_COLORS='fi=93:'$LS_COLORS LS_COLORS=$LS_COLORS':ex=41' Which are: # 41 = red background # 93 = yellow # fi = file # ex = file which is executable ...
0
votes
1answer
71 views

nemo and ls showing different filenames

I'm trying to analyze a piece of malware from the internet. I found out, that nemo browser and ls command show the filename of the malware in different ways. ls displayes filenames IMG147pgj.exe, ...
3
votes
2answers
2k views

How to distinguish a file from a directory in a ls output?

How to distinguish a file from a directory in a ls output? I want to work with files and go into directories, however, I just get a list of names of them all: for i in ls B do echo $i done
0
votes
1answer
220 views

Removing a file with special characters through terminal, which has been selected by another command

this is my first post, so go gently :) I'm creating an AppleScript which runs bash commands to select and delete the most recently modified file within a specified group of folders. The file name ...
1
vote
1answer
543 views

ls add host name prefix?

Is there a compact way to list files, with the host name prepended? My efforts to combine ls, xargs, paste and process substitution have failed me. This is the best I came up with: ls * | paste <...
1
vote
1answer
342 views

Color of 'ls' changed after zsh upgrade

I am currently using zsh 5.0.2 (x86_64-pc-linux-gnu), when doing ls the folders was showing in blue, but after an upgrade everything is in white .. When doing ls --color=auto or ls --color=tty it goes ...
1
vote
1answer
264 views

`awk -F_ “{print $1}”` not removing everything before the underscore in each line

I'm using Mac. I have a directory in which the files have names like ABC_2016-06-08_09-23.csv. I want to extract the part of each file name before the first underscore. I tried doing ls | awk -F_ "{...

1
2 3 4 5 6