Questions tagged [ls]

The ls command lists the contents of a directory.

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

Ubuntu command - awk - list files with distinct prefix

I have a directory on an Ubuntu machine with a large number of files, and subgroups of files starting with the same prefix. I need the list of distinct prefixes present in the name of the directory ...
1
vote
1answer
33 views

FreeBSD natural sort with ls and recurssion

In Ubuntu I can do a recursive search with a natural sort quite easily. A simple ls -1Rv will list file names only in a natural sort with all sub directories. An example output would be: .: test4 tmp2 ...
-1
votes
1answer
26 views

Command `/bin/sh -c ls -lh` doesn't show the output as a list [duplicate]

Running command /bin/sh -c ls, I see: > /bin/sh -c ls 20190816_212056.png Opera_65.0.3467.78_Setup.exe 20190816_212219.png ...
-1
votes
1answer
39 views

ls to recurse, showing full path

There are obviously many ways to do the same job in Linux, but I recently needed to for i in xxx through a list of each item, recursively in a tree. I found a solution with tree by doing tree -fail (...
1
vote
2answers
66 views

Explaining what this command does

ls *.txt | lp Wouldn't this command list all files that end in .txt and then print them?
0
votes
0answers
24 views

ls -s vs -l file size difference and significance [duplicate]

As a very basic linux user, I've always considered the file size as shown in ls -lh to be the one and only file size on disk. For example here, file.xlsx is 11kb -rw-r--r--@ 1 michael staff 11K ...
-1
votes
1answer
23 views

Understanding the PATH variable and soft link

Please help me understand what my-ls -l ~/bin/my-ls is trying to do? I have run the following commands on a Linux system: $ ln -s $(which ls) ~/bin/my-ls # symlink $ which my-ls /home/user/bin/my-ls ...
42
votes
2answers
6k views

Why does “ls” take extremely long in a small directory that used to be big? How to fix this?

I'm running Arch Linux, and use ext4 filesystems. When I run ls in a directory that is actually small now, but used to be huge - it hangs for a while. But the next time I run it, it's almost ...
0
votes
2answers
64 views

Error output from ls -A results in error output, why?

I have a script I run regularly using cron. I would like to get notified by email when these scripts fail. I do not wish to be notified every time they run and produce any output at all. As such, I am ...
0
votes
2answers
38 views

Sort directory list in reverse order

I'm trying to sort directory list in reverse alphabetical order. Why do I get a random order ? ls -l /usr/bin/ | sort -r Edit : I'm obliged to use the command sort.
1
vote
1answer
52 views

mkdir says folder exists even though it doesn't show with ls -a

Arch linux. I have a CIFS mount from my NAS that was mounted with full permissions # line from my fstab //IP_ADDRESS/path/to/dir /path/to/local/dir cifs uid=my_user,gid=my_group,dir_mode=0777,...
-1
votes
1answer
44 views

What does ls -A do?

What does ls -A do? I have found this shell script and I can't figure out what ls -A does. In the manual it writes that ls -A == do not list implied . and .. but I don't understand what it means. dir=....
0
votes
3answers
38 views

Print number of files excluding directories [duplicate]

I learned that 'ls | wc -l' command prints number of files in the current directory, but it includes all files and directories. Can I do the same task only for pure files excluding directories?
1
vote
0answers
31 views

Bash script does not access mounted drive [closed]

I am trying to access a mounted drive from my bash script. For some reason the script seems to have no access to it. When I type ls /mydrive in my terminal I get an output file1.txt file2.txt However ...
0
votes
1answer
43 views

Why ls -R does not list files of a pattern recursively?

ls -R lists files recursively and ls *.pdf lists all files ending with .pdf. My question is why ls does not combine these 2 functions into 1 e.g. ls -R \*.pdf to look for PDF files recursively. Of ...
0
votes
0answers
25 views

Is there a good way to use `watch` change highlighting with `ls`?

So I've been using watch to monitor a bunch of files downloading into a directory like so: watch -d ls -l dir but this is quite useless if I want to see if new files are added or old files are deleted....
0
votes
3answers
35 views

Directory listing when using setfacl ACL

I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried setfacl -Rdm g:grouptoadd:rx /path/directory/ but, I can read files (when I use ...
-1
votes
1answer
62 views

Print filename, number of line with file size and modification date

I want to print the File Name, Size of file, modification date, Number of line in a file. At present I use below command to achieve my work but it's hectic to do manually everytime ls -lrth file1.csv ...
1
vote
2answers
83 views

Making ls do a reasonable sort order, but not print Greek characters as “??”

Suppose I have the following files in a directory _y a b c x z β The following command lists them in the above order, as God intended: perl -e '@files = <*>; print join(" ",sort @...
-1
votes
2answers
43 views

Have “ls” return subdirectory in results?

Simplified situation: I'm located in ~. There is a folder ~/folder and inside, there are many, many, many .txt files named 1.txt, 2.txt, etc. I want to generate a file_list.txt inside of ~ whose ...
2
votes
0answers
77 views

sftp - timestamp | ls -l vs ls -l <file>

we have the following phenomenon sftp connectionn and then sftp> ls -l rw-r--r-- 1 530 530 36 Feb 11 08:21 test.txt sftp> ls -l test.txt -rw-r--r-- 0 530 530 ...
3
votes
0answers
39 views

Why has ls never had a parsable option implemented? [duplicate]

So we all know you shouldn't parse ls for many reasons, mostly due to filenames allowing almost every character. However why has nobody been able to overcome this in an implementation of ls? Many ...
2
votes
2answers
118 views

Does evaluating the output of “ls” make a script vulnerable to code injection?

Does there exist a sufficiently pathological filename or collection of filenames with the constraint that it must have a given prefix and suffix, say file_<your_stuff_here>.txt which would make ...
0
votes
0answers
32 views

How to generate list of groups that own files in /tmp or other file system folders?

I'm using ls -l /tmp to list the files and their permissions in tmp folder. However, how do I list of groups that own files in the in /tmp folder or perhaps in other folder in file system? I'm hoping ...
1
vote
0answers
61 views

Question marks in ls metadata output?

I was monitoring a directory containing downloads from Google Chrome with ls -la and got this in the output: -????????? ? ? ? ? ? 'Unconfirmed 784300.crdownload' I've never ...
2
votes
0answers
67 views

How to limit results from ls on sftp

I am using OpenSSH_7.4p1 on Centos 7.7.1908 and want to limit the file results from SFTP. I have logged into a server via sftp and trying to run ls -t | head -1 i.e. get the most recent file. However, ...
0
votes
0answers
20 views

block size difference in ls -s and find -size

I was trying to find the files in the current directory that are of size 1 block , so first I run the ls -ls command which show the number of blocks of each file and here is the output : total 28 0 -...
1
vote
3answers
43 views

avoid spaces and apostrophes problems with ls in a awk script [duplicate]

I have many identical files in two (local) devices, and it happens that I have renamed some, only in one device (A). I found the following way to rename the identical files in the other device (B), ...
-1
votes
1answer
184 views

ls |head (offset?)

Is there a way to paginate the ls command? For example, to get the first 50 items I can do: $ ls -U |head -50 How would I then do: $ ls -U | head -50 "offset 50" Or, does this require to ...
1
vote
1answer
40 views

Is there CLI tool like `ls`, but which also shows extra information about directory (first line from README.md, for example)

I often create small projects as separate directories in one big ~/code directory. However, with time I forget what are those directories about, and unfortunately, dirname isn't good enough to ...
-2
votes
3answers
110 views

What does lrwxrwxrwx (l…) stand for? [duplicate]

I hope you doing good. Linux Directories contain some system files usually it's hard to detect if Linux doesn't have color-coding enabled or no extension/suffix with the file. We use ls -l, ls -lah ...
0
votes
1answer
63 views

ls --color=auto, why they offer such an option since there is --color=always by default?

From man ls: With --color=auto, ls emits color codes only when standard output is connected to a terminal. Just being curious. What would hurt if I emits color when standard output is not ...
0
votes
1answer
219 views

zsh: How to set LS_COLOR to show any tar file as different color than white?

I am using zsh When I do ls: for any compressed file type such as .tar.gz, .tbz2, .zip I get them as white and not bold.On the other hand, in bash its color is red and in bold. Is it possible to give ...
0
votes
1answer
65 views

How to set $LS_COLORS variable in TTY

I'm trying to make my console gorgeous with setting custom dircolors. For that I'm doing eval $(dircolors "dircolors.ansi.dark") where dircolors.ansi.dark is my custom file with preffered ...
1
vote
1answer
220 views

How to convert LS_COLORS for Linux into LSCOLORS for BSD?

I've attemped using a LSCOLORS (BSD) generator to convert the below LS_COLORS (Linux) to a format accepted by BSD. Having read man ls on BSD, I don't think it has any support for specific file ...
0
votes
1answer
77 views

Hacker hid folder/file with name pattern from Linux ls

My server was hacked by internet hackers. The server hides any files or folders with name pattern *system-sleep* from the ls/find command. I can use some commands like chmod to the hidden folder. But ...
1
vote
1answer
657 views

Format output for ls

I'm looking for a way to list the content in a folder with output in this format: folder/file.txt Similar to the output for the git command: git ls-tree -r --name-only Any suggestions?
-2
votes
1answer
56 views

Listing files with given characters in their name

I want to list all the files, in directory I am currently in, with for example "a" in their name. I know that the first part of the command would be ls -l, but i do not know how to finish it....
0
votes
1answer
109 views

ls -lh and du -h giving different file sizes when truncate is used

I am trying to find out a way to reduce the size of a log file while it is being used. So for a file I tried this: $ yes > yeslog So data is being written to yeslog continuously. After I while I ...
0
votes
1answer
85 views

OpenWRT empty folder can't be deleted (rm -rf|rmdir) nor listed (ls) show: No error information

I've been having some issues with the filesystem in an embedded computer that runs OpenWRT. Suddenly, I'm not able to delete certain folders that are empty. I get these error messages that are very ...
0
votes
1answer
56 views

'ls -alF' doesn't list files in directories behind symbolic links?

I've grown accustomed to see file-lists like this: ll /media/sf_G_DRIVE (ls -alF) but I've recently starting to use symbolic directories, but using ll /g don't show the files, it only displays that /...
2
votes
1answer
100 views

How to list files - sorted by both filename and modified date?

I have some files with their names starting with 00, 01, ..., but there can be multiple filename with the same number i.e. 00_filename1, 00_filename2. I want to list them sorted by their names, but if ...
0
votes
0answers
23 views

What are the '.' and '..' outputs in `ls -lah`? [duplicate]

Just wondering. I'm new so sorry if this is stupid. Output: total 24K drwxrwxr-x 6 lveri tas lveritas 4.0K Oct 24 00:04 . drwxrwxr-x 7 lveritas lveritas 4.0K Oct 20 22:22 .. drwxrwxr-x 3 lveritas ...
0
votes
1answer
33 views

Two files with apparently the same name in one Unix directory

I have two files with apparently the same name in a Unix directory. How is this possible? When I used the -b option with ls, it is giving a different name. The duplicate file is automatically created ...
0
votes
1answer
59 views

Bash for loop over ls splits line at “ (” character

Currently I'm writing a bash script that is supposed to loop over some files in a directory in order of the creation date. To do so I use (with real code instead of the echo): for i in $(ls -tr) do ...
0
votes
0answers
64 views

ls colors don't match LS_COLORS variable

I am running Konsole on a SLED (v11.4) Linux installation. I have a ~/.dircolors file to set the LS_COLORS evaluated in my ~/.bashrc. After sourcing the ~/.bashrc file if I echo $LS_COLORS it shows ...
0
votes
1answer
123 views

watch tail -20 ls -ltr?

I would like to see the latest content of a directory. I tried watch tail -20 ls -ltr ./{directory} it is not working. Is there a way to constantly shows the content of a directory like watch command?
-4
votes
1answer
47 views

Finding files using /\.c/ [closed]

I was wondering if there is a way to find files that end with .c using /\.c/. How would I do that? I have tried ls -l /\.c/ but it doesn't work.
-3
votes
3answers
128 views

Linux command equivalent to 'ls' with -R argument? [closed]

I am green to Linux. I was asked to implement a Linux command to list all files in directories without ls command and with -R argument. I tried the below command: dir -R Which turns out it show all ...
0
votes
2answers
100 views

How to list attributes (esp. date) of a symbolic link's target file?

When typing ls -la we get the list of files in the current directory, with symlinks having also their target files printed. When displaying a symlink, the shell prints the attributes (and particularly,...

1
2 3 4 5
25