Questions tagged [ls]

The ls command lists the contents of a directory.

Filter by
Sorted by
Tagged with
2
votes
1answer
56 views

Grouping directories in `zsh`

Using zsh both of these command produce the same result: ls (dir1|dir2)/dir3/*.txt ls {dir1,dir2}/dir3/*.txt Using bash only the following works: ls {dir1,dir2}/dir3/*.txt So, if I want to list ...
0
votes
1answer
304 views

List all extension-only files and folders [duplicate]

I'd like to list all files and folders that only have an extension, like .bashrc, .cache/, and so forth. This seems like it should be straightforward. When I try ls .*, I don't get the expected result:...
8
votes
1answer
9k views

What does * next to the file name mean in the output of ls? [duplicate]

I have a doubt related the output of ll command. When, in my shell, I execute the ll command I obtain this output: -rwxrwxr-x 1 andrea andrea 104215 ott 15 15:56 atmosfs* Why I have the * next to ...
-2
votes
1answer
28 views

Move files from one directory to another. But, rename files before the move if the destination directory already contains file of same name? [closed]

I need to move all the text files from /abc/d1 to /abc/d2, but files need to be renamed if /abc/d2 has files with the same name already. cd /abc/d1 mv *txt /abc/d2
1
vote
0answers
317 views

ls command is too slow for some directories

When I run ls command for some directories, it may take about 1.5 seconds to complete even if directory has just a few files, but for most of directories it's very fast. It seems that it's slow for ...
6
votes
3answers
4k views

Only if in “/” : alias ls='ls -I test'?

I have the following in my ~/.bashrc to hide the listing of test from the output of ls: alias ls='ls -I test' But I want it to only hide test if my current working directory is the root (/) folder, ...
2
votes
1answer
354 views

How to use character classes

In one of my systems, when I run ls [:lower:]*, it will list all files that start with a lowercase letter. In another one, it will give an error: ls: cannot access [:lower:]*: No such file or ...
72
votes
2answers
29k views

What do the symbols displayed by ls -F mean?

I noticed that if I run ls -F on a directory, some of the entries have a * or a @ after them. spuder@ubuntu:~$ ls -F /sbin acpi_available* getpcaps* lvmconf* ntfscp* ...
0
votes
1answer
201 views

ls without --time-style support

I need the same output in FMTIME as in the following command: FMTIME=`ls -l --time-style=+%s $FILE | cut -f6 -d' '` but my Linux (running busybox) does not support ls --time-style. I am running :: ...
1
vote
1answer
504 views

“bash: /usr/bin/ls: Permission denied” Arch linux

Today I discovered that the command ls to list files, only returns the error: bash: /usr/bin/ls: Permission denied This happens for every directory I try and also when running the command as root. ...
-1
votes
1answer
15k views

list files in ascending order

I am trying to display file names(with complete path) based on the created timestamp in ascending order. if files exists: display files with complete directory path in asc order. if files do not ...
2
votes
1answer
5k views

Difference in file listing for SSH and SFTP [closed]

I have SSH access to a server and I have never bothered to use SFTP until now. I transferred a file using FileZilla to the server. However, the weird thing is that the file doesn't show up when I ...
2
votes
2answers
817 views

ls won't display Cyrillic characters properly

I've got a problem with Cyrillic alphabet. My terminal will display Cyrillic normally as well most of my programs the only exception I've found so far is ls. Instead of normal Cyrillic it displays ????...
28
votes
1answer
3k views

Why would /etc/passwd be used every time someone executes `ls -l` command?

Read from APUE, just feel curious: The password file is used every time a user logs in to a UNIX system and every time someone executes an ls -l command.
0
votes
1answer
122 views

How do I list (ls) the content of a folder/directory recursively but to a depth of only one folder/directory?

How do I list (ls) the content of a folder/directory recursively but to a depth of only one folder/directory? I have the following folder structure: folderA: folderB1: folderC1: fileD1: ...
1
vote
0answers
335 views

Sort directories before files and underscore first with ls

When using 'ls' i want to sort directories first and then all files AND sort directories/files with underscore first. Here is an example: _folder2 folder2 _file2 file I can sort directories first ...
-3
votes
1answer
604 views

List files not owned by root at the / directory

The actual homework question is List all files/directories NOT owned by root and not created in July. I can't find a way to use ls and grep to output a file ~/NotOwnedByRoot.txt find / \!...
28
votes
2answers
3k views

Inconsistent color output from `ls` command

I teach an Intro to UNIX/Linux course at a local college and one of my students asked the following question: Why are some of the files in my directory colored white and others are gray? Are the ...
21
votes
3answers
6k views

No colored output in less for the ls command

If I run ls I get colored output which I find pretty handy for quickly getting a glance of the kind of file. When I try to pipe it to less even with the -r and -R flags the coloring always get lost. I ...
1
vote
1answer
81 views

How can I know the type of each element in the output of ls -l?

I was checking what exactly each field is in the output of ls -l. The example in this post solves my question. But again I'm wondering what type of each field is. The strings are obvious. But how ...
4
votes
2answers
5k views

how to sort files by their permissions using ls?

I have a large number of files and directories in one directory. I need to sort them in terms of the permissions. For example drwx------ drwxr-xr-x drwxr-x--- I am just wondering if we can sort ...
4
votes
1answer
3k views

Question marks instead of national letters in console

I have Netgear Stora MS2000 (which uses a modified version of Red Hat) and have strange font issues while connecting by SSH. Note that this occurs both when connecting by PuTTY from Windows and by ...
2
votes
1answer
117 views

map ls -a to ls -A

I have tried to made an alias ls -a = ls -A, ending up with: bash: alias: `ls -a': invalid alias name I want ls -a without . and ... How can I get that?
0
votes
2answers
897 views

What means ls -d? [duplicate]

When I use the -d, I only have the . that is displayed on the standard output. However, I also have other files in the current directory.
2
votes
1answer
107 views

Reverse the order of file matching as arguments

I have a program that reads files in a certain order. For this example, they all have the same extension, txt {program_name} {input 1...} {output} I happen to name the output file name "a.txt" so it ...
0
votes
3answers
141 views

What is this that “ls /d*” returns?

I am running Ubuntu Bionic and exploring Bash Refs. This is an amusing but enigmatic output from ls. Is this the file description of the shell? The command ls /d* outputs autofs disk ...
3
votes
1answer
6k views

ls -l without file permissions

How can I use ls while using -l (long listing) without showing the file permissions? Right now I have the following alias for ls: alias ls='ls -lhaG --color=auto' I have found a solution close to ...
4
votes
1answer
1k views

What does a plus (+) after the file permission bits mean? [duplicate]

I ran ls and found a directory that has the + bit set: $ ls -ld /var/log/journal drwxr-sr-x+ 3 root systemd-journal 4096 Oct 1 01:23 /var/log/journal I understand drwxr-sr-x, but what is +? What is ...
1
vote
1answer
209 views

How to use the ls command to show all files except those ending in a specific string

I have a directory with files of all kinds and I wanted to use the ls command to list all of them, except those with a name that ends in .config, but I do not get how to do it.
20
votes
7answers
3k views

Avoid listing of files that end with ~ (backup files)

My requirement is to list all files in a directory, except files ending with a ~ (backup files). I tried to use command: ls -l | grep -v ~ I get this output: asdasad asdasad~ file_names.txt ...
0
votes
1answer
343 views

Why is my files “last modified” timestamp only showing the year with the 'ls' command? [duplicate]

I'm building a java service that modifies the "Last Modified" field of some of the files it works with. The service keeps copies of files in a folder, it periodically checks a database for changes, ...
0
votes
1answer
86 views

ls don't display correct color with bold in xterm [closed]

I use xmonad with xterm, seeing picture below. It displays color in xterm but ls cannot display correct color with bold font. What is showing now: My Xresources is a copy of solarized/xresources. ...
0
votes
2answers
77 views

Trying to do a Proof of Concept of poisoning 'ls' binary to hide files and folders

I am currently trying to modify 'ls.c' source file in order to hide files and folders containing the word hidden. After doing some research, I've found that this could be possible by adding this code ...
1
vote
1answer
330 views

Bash tab completion colors differ from ls colors

I have LS_COLORS and LSCOLORS both defined, but for some reason, I'm being shown different colors when I use ls versus when I tab complete in bash. I'm on MacOS. I have these lines in my .bashrc ...
6
votes
0answers
149 views

What would cause glob to list results twice? [closed]

System: Raspbian 8 on a Raspberry Pi 3 An errant space in a sudo command caused a bunch of system directories (/bin, /etc, /usr, etc.) to be moved into a subdirectory. I was able to fix it by putting ...
1
vote
0answers
59 views

How to make ls work as if it was outputting to terminal?

Colors can be adjusted with --color=always, but how to make it display the columns with default settings, nicely fitted to terminal window size?
1
vote
1answer
503 views

How to display ls --color=auto in prompt same as outside of it

When I put $(ls --color=auto) at the beginning of my PS1 it displays all in white and every filename in newlines. But when I call ls --color=auto, it displays in colors and separated by double spaces. ...
10
votes
2answers
955 views

How to keep colored output using sed

I'm using the sed command and I want to keep colored output from the previous command. The output of ls is colored, but the output of sed is not. I'm using OSX. ls -la | sed -En '/Desktop/q;p'
7
votes
4answers
3k views

How to find only directories without subdirectories? [duplicate]

Is there a way in linux to look through a directory tree for only those directories that are the ends of branches (I will call them leaves here), i.e., dircetories with no subdirectories in them? I ...
10
votes
4answers
6k views

Find directories that do not contain subdirectories

I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories. I know that I could use ls -alR and recursively parse ...
0
votes
2answers
204 views

A specific directory is completely invisible to “ls” and “ls -la”, but I can “cd” into it

This started happening out of the blue. Originally, I was able to "ls" my "Storage" folder and all 3 subdirectories were listed accordingly. ('Beta Profiles' 'OS Backups' 'Software') Starting ...
4
votes
2answers
9k views

Piping the result of ls to tail [duplicate]

I have a directory with a bunch of log files. Something like this: data170213.log data170214.log data170215.log data170216.log I'm interested in looking at the last entries of the most recent file ...
-1
votes
4answers
53 views

The most recent files in directory with a specific format in each one

I would like to have in a variable the most recent file with a specific format. exemple : in /home/test, 5 files : file_test_hadoop_20181130.csv (This is the last modified one for hadoop file) ...
0
votes
0answers
330 views

ls hangs after the machine hosting the source folder is paused

I have two instances of RHEL 7 Linux, machine 1 and machine 2. Machine 2 has a folder that is mounted to a remote folder from machine 1. It is done with command: mount -t cifs -o user=aaa,pass=...
3
votes
1answer
2k views

size of directory reported by ls [duplicate]

I understand the size reported by ls corresponds with number of inodes inside the directory, not their actual size. I have noticed peculiar behavior, when displaying directory size with ls. Here is ...
0
votes
1answer
76 views

command sort -h does not return a reasonable result [duplicate]

I tried to sort files using sort -h algorithms@algorithms:~$ ls -lh /boot | sort -h drwxr-xr-x 5 root root 4.0K Dec 28 16:19 grub -rw------- 1 root root 4.2M Dec 5 13:10 System.map-4.18.0-13-generic ...
1
vote
2answers
112 views

Omit one column in ls -hal

How do I omit the group column in the output of ls -hal? I was using ls -hal|cut -f4 --complement -d ' ' and it works find most of the time, but if I run it in / I get scrambled output: drwxr-xr-x ...
2
votes
1answer
94 views

How to write a file list with foreign names to a csv file in the terminal?

I have some files with names in foreign languages in my terminal folder. On the terminal when I do 'ls' i see the list on the right in the picture below. When I do ls -t | tail -n +2, I see the real ...
2
votes
2answers
1k views

Is there a way to get ls to listen for changes and update output similar to tail -f?

I have a process that creates many files in a known directory, and the only way to tell how far along it is is to type ls manually. Is there a way to make the output of ls update automatically as new ...
0
votes
1answer
40 views

Listing content from two directories with wildcard

I have a task to list all files from /bin and /usr/bin that contain an e that is neither at the beginning nor at the end. The wildcard is [!e]*e*[!e] and works. (Tested commands cd /bin & ls -l [!...

1
3 4
5
6 7
22