Questions tagged [ls]

The ls command lists the contents of a directory.

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

Why does echo `ls -l` does not have newlines? [duplicate]

I am running WSL (Windows Subsystem for Linux) and when I use the ls -l function on the terminal, I get new lines printed i.e. each file is on a new line e.g.: total 12K drwxrwxrwx 1 user user 4.0K ...
-1
votes
1answer
13 views

How to change font colors for directories with write permissions in ls?

When I do ls -1, I get colours that I don't like: These directories (folder1, folder2, folder3) have "anyone can do anything" permissions. (also called 777 permissions I think). I'm not partial to ...
-1
votes
1answer
31 views

What does the at sign `@` and `+` sign mean when doing `ls -l` [duplicate]

This is on macOS Mojave. I tried to get the size of directories by using du -csh */ in my home directory. But the directory Library was giving Operation not permitted. So I used sudo to do it, ...
0
votes
0answers
26 views

Concatenating files with delimiter in for loop

I'm loading data from the filesystem to postgres. I have 500 millions of single files, 1 json in each file. In order to be more efficient with postgres I want to load those in batches not as single ...
1
vote
1answer
58 views

parse through a `.hidden` file to ommit its contents from `ls`

I want to have ls ignore (ommit from its output) any and all filenames that are listed in a .hidden file. I found a bash function that appears to override ls to do this... ls () { if [ -f .hidden ]...
0
votes
2answers
61 views

Difference between `ls -d */` and `ls -d *`?

I am struggling to understand how ls -d works. I've read through the other ls -d questions but none of them ask why ls -d * doesn't work the same way as ls -d */. Why is the separator character at the ...
4
votes
3answers
133 views

ls: Display directory name when only one matches pattern

When using ls to display files matching a pattern, it displays the directory names with contents if there are multiple matches, but if there is only one match, it omits the directory name. Here is an ...
0
votes
2answers
44 views

Find all files and list all attributes in terminal

I can list all test.txt files on RHEL terminal using sudo find / -iname 'list.txt' If there is a file /media/my/list.txt I can run sudo ls -la /media/my/list.txt to get the attributes. How can I ...
0
votes
1answer
84 views

Why are my PNGs executable?

I noticed that most of my image files are green when the ls command is used but some of them look purple. Apparently .png and .jpg files are supposed to look Magenta while executable files are Green. ...
2
votes
0answers
35 views

ls output: group directory symlinks with directories [duplicate]

Using the --group-directories-first option I can group the ls output as follows: [a-z directories] [a-z files and symlinks] However, I would like symlinked directories to appear with the rest of the ...
14
votes
9answers
7k views

Is there a reason why “.” and “..” show up after doing ls -a?

If I run ls -a user@users-MacBook-Pro:~$ ls -a . .. I get . and .. (current directory and parent directory?) Is there a reason why they show up after ls -a, do they do anything ...
2
votes
2answers
58 views

List a file from all directories but skip the ones whose folder contains a specific file

I have a perl script that processes .xml files which reside in multiple folders under a directory. The script takes the absolute file path using the output of ls using parallel. parallel -j 1 /home/...
0
votes
1answer
72 views

Piping results from ls -l in a bash script

So I used: getent passwd $2 | awk -F: '{print "|Username: " $1 "\n|Password: " $2 "\n|Uid: " $3 "\n|Gid: " $4 "\n|Comment: " $5 "\n|Home: " $6 "\n|Shell: " $7 "\n"}' to pipe user info in to a neat ...
0
votes
1answer
28 views

how to make `ls` stop ignore `.` when sort items?

When trigger ls -alhF I see .ssh got placed near ssl instead of top of the list. How could I make ls to sort files and folders to be "native" (aka .ssh/ then abd-dir/ then ssl/ dir) [centos@ip-172-...
0
votes
0answers
51 views

ls --help doesn't work in terminal, why? [duplicate]

Whenever I type a command to get information on, for example: ls --help I get an error: "ls: illegal option -- -" "usage: ls [-ABCDEF...]" Can anyone help me on why my --help isn't working?
0
votes
0answers
18 views

How to keep directories sorted by interest or frequency of usage?

Current situation Let's say I have a cloud sync directory $CLOUD_DIR with sub-directories which I want to keep sorted by interest. In order to do that I use lexicographical order and use number to ...
2
votes
1answer
51 views

`ls -d */` is not working on one specific directory [duplicate]

ls -d */ runs fine in all other directories that I tried, but in one specifically, I get this: ls: invalid option -- '/' Try 'ls --help' for more information. I pasted the command in the terminal, ...
0
votes
2answers
39 views

Can i run 'ls' on text file that contain list of files and directories?

I have a text file that contain list of files and directories and i want to filter only the files. I tried this but it didn't worked: cat file.txt | ls -l | grep ^-. This is the file: /etc /etc/...
2
votes
1answer
112 views

The tilde ~ key combination doesn´t show up in bash

I am using an acer swift one laptop with Windows 10, the keyboard setting is on standard German. I downloaded bash today from git-scm.com/download/win and tried some commands. Starting of with the ...
0
votes
0answers
26 views

File browser and bash ls give different results

Im using a NAS server with AFP service for quite some while. Now I switched finally to debian buster and wanted to use my photomaniging software again. go everything up and running. A week ago I ...
0
votes
0answers
22 views

Why do newer versions of GNU `ls` have different output in command substitution when dealing with newlines? [duplicate]

The folder "/tmp/folder" contains one file, whose filename consists only of a single newline. The output of ls -A /tmp/folder, even inside a non-interactive script, is: ''$'\n' Here are the ...
0
votes
2answers
62 views

Sort contents of folder by their git time

I want to sort the files in a folder by the time they were added to git. I looked at git ls-files sort by modification time, but this gives me all the files in git by time. I want only the files/...
2
votes
1answer
40 views

Search directories containing numbers larger than a certain threshold in their name

This is the command that I have and would like to modify with an additional condition: find /home/user/backups/ -mindepth 2 -maxdepth 3 -name "*~EEEE000.tif" -print This is the output of ls /home/...
1
vote
2answers
93 views

diffrence between ls -l *.<sometthing> | wc -l and ls -l | grep <something> | wc -l

I have a folder with a huge file list that I want to count. I was doing ls -l *.json | wc -l and it was working fine, till the list apparently gone huge enough that this command didn't work any more. ...
1
vote
2answers
121 views

Why does ll -d */ result in an additional forward slash?

The command ls -d */ only lists directories as follows Desktop/ Downloads/ Pictures/ snap/ Videos/ Documents/ Music/ Public/ Templates/ The command ll -d */ limits the results to ...
1
vote
0answers
26 views

Oh My Zsh - execute ls after auto cd [duplicate]

Oh My Zsh has this lovely feature where you can just type dir-name instead of cd dir-name to access the directory called dir-name. In my old .bashrc I had a function that overwrites the builtin cd ...
0
votes
1answer
82 views

Set LS_COLORS in Alpine

I am trying to set the directory colors in alpine to be white. I tried to create ~/.profile with LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS in it. But it had no effect. I see many examples ...
1
vote
4answers
152 views

Bash - print reversed file list using glob

Is there a way to reverse a file list via glob? So I would get the same result as with: ls -r * I'm using this in a shell-script and shellcheck keeps complaining: ^--------^ SC2045: Iterating ...
0
votes
0answers
32 views

Newline delimited ls command? [duplicate]

I'm currently writing a help system for my window manager and I need to have a list of files that are delimited by newlines. I'd use the ls command but if there's the enough files ls will display ...
0
votes
1answer
115 views

why does the output of `ls` look different when piped through ``tr “\n” “\n”`?

The man page for tr(1) says: tr - translate or delete characters SYNOPSIS tr [OPTION]... SET1 [SET2] DESCRIPTION Translate, squeeze, and/or delete characters from standard ...
0
votes
2answers
53 views

list filenames stored in text file with a certain timestamp

I have stored a couple of file names in a text file by the name new1.txt in my home directory, now i'm using a loop to list all the files in the directory they are present in. I am able to write the ...
0
votes
2answers
47 views

aws ec2 ls command is showing the user@ip:directory/folder on the last line - How can I remove this from my ls output?

When I perform an ls command in my aws ec2 server, I am getting the correct list of files which I need, but for some reason the user@ip:directory/folder is showing on the last line of my results? Is ...
0
votes
0answers
46 views

How to solve -ksh: /bin/ls: cannot execute [Argument list too long] error? [duplicate]

I wrote a command line expression to generate count of files and directories in source file but I get -ksh: /bin/ls: cannot execute [Argument list too long] How to solve this issue? I used ...
0
votes
0answers
18 views

Why the following redirection doesn’t work? [duplicate]

i typed the following command which cp | ls -l It didn’t work as i expected. I wanted that the output of the which command will be a path name. So the ls command will show the information about the ...
13
votes
4answers
1k views

How to add new line between `ls -l` output

This is standard ls -l output. user@linux:~$ ls -l total 0 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file01 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file02 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file03 ...
1
vote
2answers
41 views

Find a file and send email

I want to find a file for every 60sec. If the file exists between the time range then an email should trigger. i tried below but not working. Apprecite your help ! THanks Advance #!/bin/sh cd /my/...
1
vote
2answers
57 views

Drop stderr from ls

When I run ls on a filename that doesn't exist the output reports that. I'd like to drop that output but still report when a file is found. Is this stderr that reports the output below? $> ls foo ...
3
votes
1answer
216 views

Why does `ls` add a leading whitespace to its output for certain directories?

If I use the ls command in my home directory each line of output has a leading whitespace: $ ls bin Documents ... It only seems to do this for my home directory. Why does it do this? Note: I ...
1
vote
1answer
83 views

Difference between /$ and ~$

When I log into a server running Ubuntu 18.04.3 (LTS) x64 and run ls nothing shows and there is a ~$ at the end of the command prompt. When I type cd / the prompt changes to /$ and I can see many more ...
2
votes
1answer
73 views

How can I show hidden files with grep and ls? Problem with period ('.') at the beginning of the word

I'm trying to display hidden files in the current directory using grep and ls. The following command works fine: ls -a | egrep '^\.+', but this commands don't work: ls -al | egrep '\<\.+' or ...
1
vote
2answers
105 views

ls: use different color for “user” and “group” columns, when file owned by root

When using ls -lAhF, the 3rd and 4th columns are user and group ownership, ie: drwxrwxrwt 2 root root 60 Nov 15 15:50 .X11-unix/ srwxr-xr-x 1 marti marti 0 Nov 15 15:51 .menu-cached-:0-marti= ...
2
votes
2answers
115 views

`ls -l ~~` (two tilde)+ tab does not show directories starting with ~~, but users

In the bash shell, why does ls -l ~~ + Tab not show directories starting with ~~, but users? (all users). The ls -l is just an example. If I type ~ + Tab in any directory, I get a list of users.
1
vote
3answers
92 views

For loop to find files of largest size and copy them to another directory

I am trying to create a loop to sort files within each of many directories by size, then copy the largest two to another location, keeping the directory format (below). folder/sample 1 .../...
0
votes
1answer
347 views

How does one have custom LS_COLOR work for ZSH?

I wanted to make custom colors for the ls command with zsh, but I find that all the previous answers to this do not work for me. I tried all these options: Option 1) #LS_COLORS='no=00;37:fi=00:di=...
0
votes
0answers
34 views

How do I change the way lists are presented in the terminal?

I'm new to working with the terminal and recently I have watched a few videos online, and customized it a little bit to suite my workflow (Color Schemes). My issue is that some of the directories I ...
0
votes
1answer
40 views

Using paths from a function that uses globbing

It is known that parsing the output of ls is generally a bad idea and one solution is to use globbing instead of ls to 'safely' loop through files in a directory. for path in /path/to/search/*; do ...
0
votes
1answer
52 views

`ls -l` doesn't display the human-readable owner and group, how can I check the owner and group of a file?

I want to check the owner and group of a file, but I get: $ ls -hl canal.properties -rw-rw-r-- 1 500 499 514 Nov 4 19:12 canal.properties 500 and 499 are not human-readable, are there any other ...
0
votes
1answer
737 views

Difference between ls command options:`ls -a` `ls -al` `ls -all`

First look at the output of ls --help command: Several lines ignored in the output -a, --all do not ignore entries starting with . -l use a long listing ...
34
votes
4answers
4k views

Why would the command “ls *” generate an error about invalid options?

There is a thread that talks about ls "*" not showing any files, but I actually wonder why the simple ls * command doesn't output anything in my terminal other than ls: invalid option -- '|' Try '...
0
votes
0answers
24 views

Grub2 shell ls command shows nothing

in the Grub2 shell you have the ls command to show your drives. But, in my case, ls shows nothing, really nothing. lsmod shows a bazillion loaded modules, to be sure, I loaded these again: ls, ...

1
2 3 4 5
22