Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ls]

The ls command lists the contents of a directory.

2
votes
1answer
17 views

Why the output of ls is different for the same directory /dev/fd/ based on the method of referencing this directory?

cd /dev/fd/; ls Gives me output that I expect: 0 1 2 255 But: ls /dev/fd/ Gives different output that I don't expect: 0 1 2 3 Why? What happens here? What happened to file descriptor 255? ...
1
vote
1answer
25 views

How do I cd and then ls in my cshrc

I want to be able to cd into a path and have it ls automatically. I have tried doing a function such as cs() { cd "@a" ; ls} but this results in an error saying "badly placed ()" so I do not think I ...
0
votes
1answer
23 views

read issues with ls -i

If I write: ls -i '/home/user/Desktop/file' | awk '{print $1}' I get the inode number of the specified file. I want to make a script that gives me back the inode number of a certain file. If I do: ...
1
vote
3answers
36 views

How to create a recursive manifest directory

I need to create a manifest of thousands of files and their directory paths recursively. Here is an example of how i need the manifest to output This_is_an_example/of_how/i_want_to_display/...
0
votes
2answers
30 views

Find files greater than X value, sort by size, show in ls format

I am extremely confused, since a command I'm rather confident in, returns something completely different than I imagine! My assignment is simple: Find files (in a specific directory that is given) , ...
0
votes
1answer
51 views

display ls output in 2 columns with directories in one and files in the other

Can you make an alias command that basically formats the out put of ls into two columns, so that the output shows all the subdirectories in column 1 and all the files in column 2. Example: me:~$ ls ...
0
votes
0answers
38 views

ls flag that shows files in MB in OSX Terminal

the ls -l --block-size=M flag does not seem to work in the OSX terminal, which is what I typically use in a linux terminal to show file size in MB. Does anyone know of a OSX variation for ls that ...
-1
votes
3answers
25 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
1answer
28 views

Is there a simple way to group soft links to directories with directories when using --group-directories-first?

I like the --group-directories-first flag for ls. My .zshrc has this line in it: alias ls="ls -h --color='auto' --group-directories-first" The only thing I don't like is that symbolic links to ...
0
votes
1answer
44 views

? at the end of files in while listing file using 'ls'

While listing files using 'ls' command I get the following. -rw-rw-r-- 1 vineesh vineesh 2026 Nov 28 15:48 cdfg_ulit_89.txt? -rw-rw-r-- 1 vineesh vineesh 1215 Nov 28 15:48 cdfg_ulit_8.txt? -rw-rw-...
7
votes
5answers
2k views

How to list *.tar.gz, one filename per line?

I am trying to list every .tar.gz file, only using the following command: ls *.tar.gz -l ...It shows me the following list: -rw-rw-r-- 1 osm osm 949 Nov 27 16:17 file1.tar.gz -rw-rw-r-- 1 osm osm ...
0
votes
1answer
35 views

How do I get rid of human readable format for ls?

My ls -l command automatically prints file sizes as human readable. I have tried exporting BLOCKSIZE in my bash profile in various formats to change this but literally everything I have tried on the ...
0
votes
2answers
33 views

What does <F6>q mean in ls command output?

I used ls ~ on RHEL 7 but I got q as output! What does it mean? [user@server2 ~]$ ls /home/user/ <F6>q [user@server2 ~]$ ll total 4 -rw-r--r--. 1 root root 340 Sep 18 17:16 <F6>q [user@...
0
votes
3answers
99 views

Why ls | wc outputs 3 lines in dir with 3 one-line files? [closed]

$ ls 1.txt 2.txt 3.txt $ ls | wc 3 3 18 All three files has only 1 line, but ls|wc outputs '3'.
-3
votes
1answer
33 views

Gnu/Linux: Listing files, with certain characters in the file-name, while in a different directory

How do I list all files and directories in the /etc/ directory, which have one or more digits in its file-name, and save the output to a file, in the home directory. The output must have the full ...
0
votes
0answers
19 views

Effect of environment on binutils string sorting order [duplicate]

What is the default string sorting order of ls and sort? According to man 1 sort, the variable LC_ALL determines the order, but I can't determine which locale code corresponds to my default sorting ...
-1
votes
0answers
59 views

Problem: Don't understand certain output of ls colors

Background: When I type in 'ls', the files and directories within a certain directory are listed. Each type of file/directory in a different color. The output is like this: The 4 files/directories ...
3
votes
1answer
69 views

Alternatives of ls: dir and vdir [duplicate]

When I check the coreutils, I found that GNU Coreutils 10 Directory listing This chapter describes the ls command and its variants dir and vdir, which list information about files. • ls invocation: ...
7
votes
1answer
445 views

Why ls without -l return 1 when permission to directory is r--

I have read this and this, and found that my problem is different and more specific. I understand the following points. +x on the directory grants access to files inodes through this specific ...
2
votes
3answers
142 views

List only regular files [duplicate]

I desire to list all inodes in current directory that are regular files (i.e. not directories, links, or special files), with ls -la (ll). I went to the man ls searching for type and found only this ...
0
votes
1answer
27 views

Distinguish a command not a native second transmitter

suppose [root@iz2ze9wve43n2nyuvmsfx5z /]# find . -maxdepth 2 -type d | ls bin dev home lib64 media opt root sbin sys usr boot etc lib lost+found mnt proc run srv tmp ...
-1
votes
1answer
43 views

Find files in specific directories

I have a college exercise which is "Find all files which name ends in ".xls" of a directory and sub-directories that have the word "SCHEDULE", without using pipes and using only some of the commands ...
0
votes
2answers
43 views

Why `ls -d` only demonstrate `.`?

I'd like to only the directory $ ls -d . #get . on macos and the same on centos [root@iz2ze9wve43n2nyuvmsfx5z ~]# ls -d . . I find the solution: [root@iz2ze9wve43n2nyuvmsfx5z /]# ls -d */ bin/ ...
0
votes
2answers
135 views

ls error code 2

I was reading the man of ls and in the end it talks about the Exit status of ls. It says: Exit status: 0 if OK, 1 if minor problems (e.g., cannot access subdirectory), 2 if ...
0
votes
1answer
37 views

ls: ordering by timestamp (reversed) and if the timestamp is the same order by name (not reversed)

I'd like to order a directory by reversed timestamp, but if the timestamp is the same order by name (not reversed) Using ls -tr if two files have the same timestamp order by name but in reversed mode
2
votes
1answer
173 views

nesting brace expansion and command substitution

I want to create a simple bash-script that checks whether a directory contains all the files whose names contain numbers from 1 to N. # Creating some files for testing $ cd /tmp/ $ mkdir test $ touch ...
-2
votes
1answer
46 views

A directory showing up in itself [closed]

I do cd ~ and then pwd. It shows /root. Then I do ls. It again shows root. This is NOT another directory with the same name because when I do cd root, it says -bash: cd: root: Not a directory. ...
0
votes
1answer
28 views

directory listing command error after install google-authenticator on CentOS 7

Status CentOS 7.5.1804 (Core) Linux 3.10.0-862.14.4.el7.x86_64 Problem After I installed and setting google-authenticator packages, weird authentication related message keep shown when I use ...
0
votes
2answers
114 views

Using regular expression for rm and ls

QUESTION: What is happening here and how do I fix it? PROBLEM: When I do: $ls | grep -P "file[1-9]{3}.txt|file[1-9]{2}.txt" I get: file11.txt file12.txt file13.txt file14.txt file15.txt file16....
-3
votes
1answer
151 views

Why exit status of command “ls” is difference between bash and csh shell?

Why exit status is different between bash and csh shell?, In ls man: Exit status: 0 if OK, 1 if minor problems (e.g., cannot access subdirectory), 2 if serious ...
1
vote
1answer
50 views

Why are some files in bold & others not? [duplicate]

I getting a permission denied when trying to copy my cisco image to the switch and I thought the bold text may indicate something I was unaware of.
1
vote
2answers
54 views

display permission for all files that start with -

I need to display the permissions details for all the files names in a directory that begin with just "_". I have tried various commands using ls and find and no joy.
-1
votes
2answers
68 views

system directories don't appear in “ls” output [closed]

When I ls all files in CentOS 7, I get very few directories and there's no bin, no lib etc What happened here?
1
vote
1answer
112 views

How does this work ls *[^0-9]* [duplicate]

I am learning the wildcards. I see that ls *[0-9]* would list all the files/directories with numbers in its names so shouldn't ls *[^0-9]* list all the files/directories without numbers in the ...
0
votes
4answers
61 views

Sort directory files by number

I have this directory $ ls 0 2 4 config.yml 1 3 catalog.svg The subdirectories are numbered starting from 0. I need to get the maximum number. When trying ls | sort -n I get 0 ...
19
votes
7answers
2k 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 ...
2
votes
3answers
457 views

type ls command [duplicate]

so i studied somewhere about the type command and came to know that type command can provide the location of command used with it,more specifically the location of the executable file associated with ...
7
votes
1answer
204 views

Why is the first field in 'ls - l' not a 'f' when viewing a file? [closed]

When I do 'ls -l', I might get something like this: -rw-r--r-- 1 root root 209 Mar 30 17:41 fname The first field is the -, which means this is a file. If it was a directory and not a ...
0
votes
0answers
37 views

dot at the end of mode column of ls long output format [duplicate]

To list files and directories by using ls -l on CentOS, I saw a dot at the end of ownership or mode column. For example, drwxr-xr-x. 134 root root 12288 Sep 20 09:59 etc What does this dot mean?...
0
votes
0answers
67 views

ls ~ permission denied with xonsh in Cygwin

I tried to use xonsh in my Cygwin terminal, but ran into some problems with permissions: loom@tatooine ~ $ ls xonsh: subprocess mode: permission denied: ls However, I can use the command ls as ...
1
vote
2answers
58 views

Finding filenames that end in a specific character with or without an extension [duplicate]

I have a bunch of files in a folder that all end in a different version number, like 1, 2, 3, etc. Some of them have extensions, some of them don't. Is there any way I could use a command like ls, ...
1
vote
3answers
128 views

Using ls to find files that end in a character, ignoring extension

I am supposed to use ls to find files that end in a certain letter, but it does not matter if the file has an extension or not. For example, I want it to do this > ls test test.txt test.ascii ...
1
vote
1answer
138 views

xargs: 'ls' terminated by signal 13 [duplicate]

find . -type f -print0 | xargs -0 ls -ltr | head -n 10 | awk '{print $NF}' | xargs rm This command is giving me this: xargs: 'ls' terminated by signal 13 However, it's executing fine. It's supposed ...
2
votes
1answer
45 views

Expect wigs out when I use the single quote in [exec ls -h | grep '\.foo' ]

I am trying to store a list of specific files into a variable in expect. In my script, I am trying to compile files that have different file extensions, like .foo, .bar. In this example, I have the ...
1
vote
2answers
195 views

ls -F OR ls -al - What does the red highlighting mean? [duplicate]

So I ran a ls -F or ls -al on my /usr/bin directory and some of my files showed up with a red background and white text. What does this mean?
1
vote
5answers
147 views

How to prevent `ls` from sorting the output?

I have a specific order of files that I want to list if they exist; around 40 files. Some kind of precedence. So I tried: ls -1d /opt/foo/lib.jar /opt/bar/lib.jar I expected this to list /...
2
votes
1answer
154 views

Locomotive doesn't work on a debian system: sl ls

PROBLEM: I installed sl but when I type sl on the command line I get this: bash: sl: command not found (root@host)-(03:55:38)-(/home/user) $apt install sl Reading package lists... Done Building ...
-2
votes
1answer
53 views

du reports directory size as much smaller than the sum of its contents

I have a directory ~/D that I'd like to find the size of. using du -c ~/D/* gives 26880. However, if I run ls -l ~/D, then I can clearly see that the individual files add up to much more than 26880. ...
-1
votes
1answer
83 views

ls and du disagree about file size, by a few orders of magnitude

Does anyone understand why I might get these results? Note the discrepency in file size between the two commands below: $ ls -lh gauss_landmarks_0000.npy -rw-rw-r-- 1 dparks dparks 1.1G Aug 16 12:43 ...
0
votes
0answers
22 views

How can I determine the “alternate access control method” when the access flags in ls end with a `+`

On my Ubuntu, the directory in which pluggable media is mounted (/media/me) is owned by root and has access flags drwxr-x---+, so without the "alternate access control method" indicated by the + I ...