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
37 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
64 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 ...
2
votes
1answer
32 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
39 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.
0
votes
1answer
32 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
29 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. ...
28
votes
1answer
2k views

Inconsistent color output from `ls` command

I teach an Intro to UNIX/Linux course at a local college and one of my students ask the following question: Why are some of the files in my directory colored white and others are gray? Are the white ...
0
votes
2answers
51 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
34 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 ...
1
vote
0answers
50 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
33 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
487 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'
-2
votes
0answers
73 views

What is the purpose of the -d argument to ls? [duplicate]

I currently study bash commands and in my tutuorial I have this command: ls -d I try to understand what is meaning of -d with ls I tried to run it on my computer and I get this result -> . I tried ...
6
votes
4answers
755 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 ...
0
votes
0answers
27 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=...
2
votes
4answers
68 views

Listing files recursively, grouping by user and summing its size

I need to verify the size occupied by each user on my Linux server (all files recursively inside my data folder). With the code below I can get all of my files and their users, but I don't know how ...
0
votes
2answers
33 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 ...
6
votes
0answers
68 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 ...
2
votes
1answer
63 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
581 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
2answers
88 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 ...
1
vote
1answer
30 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 [!...
0
votes
1answer
57 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 ...
0
votes
3answers
78 views

Match file names with prefix, few digits and a suffix regex

How do I match file names abc_NNN.xyz? here is the directory content [root@ tmp]# ls -ltr total 0 -rw-r--r--. 1 root root 0 Jan 3 00:42 abc_123.xyz -rw-r--r--. 1 root root 0 Jan 3 00:42 abc_234.xyz ...
0
votes
0answers
41 views

Trouble getting to Desktop directory, with Bash on Microsoft's Windows (WSL)

I'm using the Bash terminal for Windows and currently this is what I get when I type ls -a <username@userPC>:/$ ls -a . bin data home lib64 mnt root srv usr .. boot dev init lost+found opt run ...
0
votes
1answer
66 views

Identify the file type if ls -l shows ? (question mark)

I am getting question marks and not able to identify the type of file displayed using ls -l. File types are always displayed as ???. Can you suggest a solution here?
0
votes
2answers
40 views

Move the oldest files into a directory, source directory has more than 10,000 files constantly incoming

I am working on a command to move the x number of oldest files(FIFO) into a directory, is it better idea to pipe the "find" result into "ls" or just use the "ls" .. please suggest. ls -ltr `/bin/...
1
vote
2answers
205 views

ls -I myExecutable is listing the rest of the dir files instead of showing info about the file

Working on Raspian, after compiling using make, I do a ls -I myFile in order to see the permissions of the file and if it is marked as executable as it should and instead of getting something like ...
0
votes
5answers
54 views

List files in ascending order and greater than a given value

I have some log files which has a standard prefix. dev-app.0001 dev-app.0002 dev-app.0003 dev-app.0004 dev-app.0005 dev-app.0006 dev-app.0007 dev-app.0008 I have a metadata file which has when this ...
6
votes
2answers
110 views

Why does GNU Core Utilities stat (including du and ls) report the following sizes (ext4 in GNU/Linux)?

If I have the following contents in a directory: empty_dir: Empty directory. empty_file: Empty file. one_char: File consisting of one character. several_blocks: File consisting of several blocks (but ...
0
votes
2answers
96 views

case insensitive, list files in directory, ending in .jpg [duplicate]

I'm trying to write an alias to list all the files in a directory ending in JP(E)G in its various forms. The ones I'm looking for it to recognise are .jpg .JPG .jpeg and .JPEG. Is there a form of ls (...
2
votes
1answer
23 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
36 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
56 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
51 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
83 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
550 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 ...
-1
votes
4answers
43 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) ...
1
vote
1answer
34 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
56 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
61 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
59 views

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

I used ls ~ on RHEL 7 but I got <F6>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>...
-1
votes
3answers
124 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
36 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 ...
3
votes
1answer
102 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
454 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
447 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
121 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 ...