Questions tagged [ls]

The command to list the contents of a folder/directory in Unix and Unix-like systems.

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

Pipe the output of “ls -G1” to “sed” while retaining output colors in macOS

When using the terminal in macOS I created an alias in ~/.bash_profile that lets me list folders and files in one column and with color using the -G1 option like this: something = "ls -G1" This work ...
0
votes
0answers
15 views

Can I control the levels of recursion when I run ls -R?

Background You can recursively list directories with ls -R: -R, --recursive list subdirectories recursively But the man page makes no further mention of controlling the levels of recursion. ...
0
votes
1answer
35 views

Long listing format ls command [special character file data]

When using the ls -l command files that are not Character special file (c) or Block special file (b) before the last modification date they have just one number; the file size. Those 2, have 2 number ...
0
votes
0answers
24 views

Getting `ls` without `-l` to mark out symlinks that are directory

I have aliased ls to ls -F in order to get directory, symlink, executable (etc) markers on ls's output. The output is similarly colorized by setting CLICOLORS. Unfortunately, this does not ...
0
votes
2answers
29 views

List only files for current user

How can I limit ls to only show files where I am the owner? I might be able to string together something using find along with ls, but I'm looking for an ls only solution.
2
votes
1answer
52 views

How to ls --group-directories-last?

The question is basically the same of this post, however there are 2 things that I don't like in the accepted answer: it breaks the natural column structure of ls; tac inverts the order of the output ...
0
votes
0answers
42 views

iTerm2 ZSH LSColors - Different for different iTerm2 profiles?

My LSColors look fine when the iTerm2 profile makes the background black, but when occasionally I want the background to be another color, the LSColors will not look great. How can I make my LSColors ...
2
votes
2answers
257 views

Bash Script to delete oldest files but keep latest files including sub-directories

I'm trying to delete old files but should keep latest 3 days log files.i tried below command, ls -tr /home/httpd/htdocs/pathname/pathname/config//build/logs/apps/.log | tail -n +4 | xargs rm -- but ...
33
votes
1answer
5k views

Why does the `ls` command sort files like this?

As I was trying to reverse engineer the ls command, I came upon an interesting behavior. When I make 3 files, foo.png, foopa.png, and fooqa.png, ls sorts them as foopa.png, foo.png, and fooqa.png. I ...
0
votes
1answer
943 views

Use awk command to output of ls command

I have a e-book directory that has following format: <authorname> <authorsurname> - <bookname> I want to separate the books by authors. I use the below command in a for-loop for ...
0
votes
1answer
63 views

How to align the columns of ls command output in Xubuntu 16.04.6?

I have this function in .bashrc : { ls -lhNGhgF --color=always --group-directories-first --time-style="+%d-%b-%Y $newline%H:%M" | awk ' { $3 ="\033[1;31m" $3 "\033[0m"...
2
votes
1answer
49 views

Why an empty directory has large volume?

All the directories below are empty [user@xxxx ~]$ ls -lah /home/1m total 387M drwxr-xr-x 22 foo foo 4.0K Apr 17 22:49 . drwxr-xr-x 10 foo foo 4.0K Apr 17 22:49 .. drwxr-xr-x 2 foo foo 9.2M Apr 17 ...
1
vote
2answers
1k views

Run `ls` recursively with wildcards

I'm trying to find all the project files of a particular file type with: ls -ltR *.mb I know there are the files I want in several folders, but I get no results back. What did I do wrong?
0
votes
4answers
59 views

Enumerate files *.pdf exclude *_book.pdf

How can enumerate all file file in dir, exclude by pattern. For example: all *.pdf exclude *_book.pdf. I try so: for $PDF in $(ls *.pdf | grep -v *_book.pdf); do echo "File $PDF" done It is a ...
0
votes
1answer
623 views

dir / ls not displaying files outside of root directory in Windows 10

I've been trying to point to files and directories via my command line or powershell in windows, but for whatever reason the dir or ls command will not display files or folders within the directory ...
2
votes
2answers
118 views

Exclude system entries with “ls” or “find”

Compare Cygwin: $ ls -1 -N /cygdrive/c $Recycle.Bin cygwin64 Documents and Settings pagefile.sys PerfLogs Program Files Program Files (x86) ProgramData Recovery System Volume Information Users ...
0
votes
1answer
25 views

Invisible directory names

When I do ls -l I get the picture below and I have no idea why. I know the names of the directories and I can cd to them no problem but can't see the actual names. How do I fix that?
12
votes
1answer
5k views

Why does ls wrap some filenames in single quotes?

I've noticed that when I do ls in a terminal, some filenames are wrapped in single quotes and some aren't. I don't like the way this looks as I prefer my terminal outputs to be nice and uniform. ...
0
votes
2answers
341 views

What's the difference between these ls command line arguments: -d vs *

What's the difference between ls /example or ls /example/ vs ls -d /example/* Why do they give (almost) the same output?
1
vote
2answers
158 views

How do I show all the files in a directory with a name containing a number?

How do I show all the files in a directory with a name contain a number? I tried ls [0-9] textfiles (textfiles) is my directory. This is how my Linux pocket guide shows me. I am just trying to ...
0
votes
1answer
284 views

Remove the padding spaces in the `ls` result on macOS

When I run command ls on macOS, it shows the folder names with same length, padding spaces for short folder names: jihu@ksm1 Home $ ls bin code devel opt personal shared While on ...
1
vote
0answers
4k views

ls command not working in the home directory

The ls command works fine for me in all other directories except my home directory, where I get the following error: * Exit with code 1, no result found, command line was:?? locate -b -i [\^g]*g[\^a]*...
1
vote
1answer
46 views

Why are files lwith the same time stamp not sorted alphabetically when listed using “ls -lt”?

I read that ls -lt will order files by modification time before sorting by lexicographical order. However, when I use the command with this syntax, I get this result: ls -lt total 192 -rw-r--r-- 1 ...
0
votes
1answer
145 views

Can't show manual pages for `ls` in Vagrant

That's my first question in here and I'm still a beginner so please bear with me. I'm having a Linux Command Line Basics course on Udacity. I got to the point where I'm asked to open a manual page for ...
0
votes
2answers
50 views

Preview current directory in shell

What often happens when I work in a shell - zsh - is that I have cded somewhere and I want to have a quick look at the directory. Using ls may produce a lot of output and leaves it in the terminal. ...
4
votes
3answers
4k views

'ls' command very slow

I have about 17k files in a directory. When I run ls directory, I have to wait for about 15-20 seconds before the results are displayed. On the other hand, when I run ls directory | wc -l or ls ...
1
vote
2answers
282 views

ls -l shows symlinked directory with two trailing slashes

I just copied my ~/.config directory to another and symlinked it back to $HOME. When I run ls -l this shows up like this with the double slash at the end: lrwxrwxrwx 1 lud lud 22 Jul 23 20:25 ...
0
votes
1answer
927 views

'ls' output doesn't show color anymore in macOS High Sierra

I use zsh and oh-my-zsh: As shown in the screenshot ls is not showing color output anymore. I set color theme from iTerm2 and set zsh theme (wezm+ theme) from oh-my-zsh. I try to set manually ...
3
votes
1answer
245 views

find or ls does not list all files in a folder in MacOS (HFS+)

ls or find command do not seem to locate all files located in a specific folder. I'm running a Mac (under El Capitan 10.11.6 (15G21013), 500GB SSD, HFS+). In one of my folders, where I have about 700k ...
1
vote
1answer
25 views

File/directory in the CentOS looks weird

I am connected to CentOS server via PuTTY and I see a weird file/directory in one of the sub-directory which looks unreal. I am not sure how the file exists there and Its not related to our work. Can ...
1
vote
1answer
3k views

'ls' command in terminal is showing all files and file permissions. How do I get back to normal with 'ls' showing only normal files and folders?

Want to get the terminal back to bryce@macbookpro instead of bryce@machine and have the 'ls' command only show visible files and folders.
8
votes
2answers
2k views

How to color output columns of ls?

Title kind of says it all: I would like to get those neat colored columns of the output of something like ls -al, say, as in 10basetom’s answer to this question.
0
votes
1answer
93 views

dot “.” and “..” hidden files taking up space in empty directory

When I ls -ltr on the danny directory, it shows that the quarantine directory size as a little over 2 megabytes. Then I go to the quarantine directory and do an ls, and it has nothing in it - it is ...
0
votes
1answer
481 views

simple way of describing / tagging files in bash

Is there a quick and simple way to tag files in bash so that a list like this one -rw------- 1 root 88039 Sep 29 16:31 7CCE2EC3-3191-4379-C036-1C48CCCE4C6C -rw------- 1 root 1985554 Sep 27 16:09 ...
1
vote
1answer
88 views

How do I get a list of the fullpaths of every .git subfolder in a directory tree?

I am unable to figure out the right set of commands in a Windows Command prompt FOR /? or bash ls to do this. The following batch file I wrote demonstrates what I want, but I would like to know if ...
-3
votes
1answer
374 views

How to create tar file like this?

I need to create a .tar file testDay00. When I run the command ls -1, the output should look like this
0
votes
2answers
2k views

Bash: List files with absolute paths, one per line, no other information

I am looking for a command that lists all files in the current directory. Requirements: Absolute paths One file per line No other information (like size, permissions...) Don't show folders What I ...
2
votes
1answer
170 views

ls(1) acts strangely when input is a variable / subcommand or just typed

D I'm facing a issue on ls(1) that I'm almost sure that it's a silly thing that I'm just letting pass away. Anyways, I can't understand really why this isn't working. I'm using bash for cygwin (Don'...
0
votes
1answer
170 views

How to add a background color to a executable, without replacing the foreground color?

Currently I setting the ~/.dircolors file to: LS_COLORS='fi=93:'$LS_COLORS LS_COLORS=$LS_COLORS':ex=41' Which are: # 41 = red background # 93 = yellow # fi = file # ex = file which is executable ...
0
votes
1answer
69 views

nemo and ls showing different filenames

I'm trying to analyze a piece of malware from the internet. I found out, that nemo browser and ls command show the filename of the malware in different ways. ls displayes filenames IMG147pgj.exe, ...
3
votes
2answers
2k views

How to distinguish a file from a directory in a ls output?

How to distinguish a file from a directory in a ls output? I want to work with files and go into directories, however, I just get a list of names of them all: for i in ls B do echo $i done
0
votes
1answer
208 views

Removing a file with special characters through terminal, which has been selected by another command

this is my first post, so go gently :) I'm creating an AppleScript which runs bash commands to select and delete the most recently modified file within a specified group of folders. The file name ...
1
vote
1answer
510 views

ls add host name prefix?

Is there a compact way to list files, with the host name prepended? My efforts to combine ls, xargs, paste and process substitution have failed me. This is the best I came up with: ls * | paste <...
1
vote
1answer
291 views

Color of 'ls' changed after zsh upgrade

I am currently using zsh 5.0.2 (x86_64-pc-linux-gnu), when doing ls the folders was showing in blue, but after an upgrade everything is in white .. When doing ls --color=auto or ls --color=tty it goes ...
1
vote
1answer
251 views

`awk -F_ “{print $1}”` not removing everything before the underscore in each line

I'm using Mac. I have a directory in which the files have names like ABC_2016-06-08_09-23.csv. I want to extract the part of each file name before the first underscore. I tried doing ls | awk -F_ "{...
3
votes
1answer
1k views

How do I show hidden files beginning with a certain letter in Linux?

I'm trying to show hidden files that begin with the letter b. I have tried: ls b ls b* and many other options but can't find a solution. How can I do this?
0
votes
1answer
245 views

Mac OSX Terminal ls, cd & ditto command return odd results

My MacBook Pro (Retina, 13-inch, Late 2013) running OS X El Capitan has some weird thing going on with terminal and more specifically when I run the ls, cd or ditto commands. I have my disk ...
0
votes
2answers
321 views

Combine tabnew and ls in vim

When I need to open a file in a new tab in vim, I do :tabnew relativepath/filename. I find it difficult to hunt for files from tabnew. It does auto-completion and it even cycles through items in a ...
0
votes
3answers
924 views

Why won't ls command show users in home directory?

In unix, when I create a user with useradd it creates their home directory in /home by default. But I specified another user to have its home directory in /home/summer. When I use the ls command ...
0
votes
0answers
243 views

ls /dev/sda2 - same as dir c:

I want to install linux mint. The problem is, I have drive c and d. I want to install it in drive c. I think it is /dev/sda2 but I`m not sure. I want to dir this drive to see files and check if I can ...

1
2 3 4 5 6