Questions tagged [ls]
Questions relating to the Linux 'list' command (ls)
382
questions
5
votes
1
answer
2k
views
Summarize file sizes of a directory structure?
I have written a small backup script with rsync. I would like to monitor its progress by comparing the total file sizes on the source and destination directories. du Is inaccurate because it measures ...
5
votes
1
answer
6k
views
ls invalid option '2'
I have the following files (among others) in a directory. I’m running Ubuntu 16.04.
484 May 8 21:50 NA19239.vcf
484 May 9 08:50 HG01583.vcf
484 May 9 08:51 HG01595.vcf
0 May 9 15:11 HG00268-...
4
votes
4
answers
1k
views
Why doesn't ls combined with awk show exact sizes?
I am trying to find the size of the files on my hard drive in exact bytes, but whenever the size gets too big the number turns all weird (like 1.98329e+12). Can I stop it from doing this or convert ...
4
votes
3
answers
4k
views
Size of device file ( missing in ls -l output )
When I try to print the device file output shows binary data in hexadecimal format. But upon doing a ls -l /dev/sda I get:
brw-rw---- 1 root disk 8, 0 Jan 29 12:29 /dev/sda
I don't ...
4
votes
2
answers
79
views
Examine a folder named `-F/` [duplicate]
I think this folder was probably created by accident at some point, but I can't ls or cd to it to check.
Things I have tried:
ls '-F'
ls "-F"
ls \-F
ls \\\-F
ls \\-F
and the cd equivalents
4
votes
1
answer
3k
views
Difference between output of `ls -sh` and `ls -lsh` [duplicate]
$ ls -lsh file.qcow2
204K -rw-r--r-- 1 root root 193K Jul 19 15:18 file.qcow2`
$ ls -sh file.qcow2 204K file....
4
votes
2
answers
479
views
Is there any way to control ls output format
I have a directory contains some svg images among its contents. I list them with following ls command to save the output in a file:
ls *200px.svg > animList.js
The output file looks like:
file1-...
4
votes
1
answer
2k
views
Strange terminal navigation when logged in as new user
I am not even sure how to ask this properly..
I am using EC2 Ubuntu 12.04 I added a new user
sudo useradd -g admin admin
sudo adduser admin sudo
Changed shudders so I can use new user without ...
4
votes
2
answers
269
views
List dates of files with sed
I am trying to extract the date modified/modified last week files and folders with sed but i am strugling.
Here's my opinion
ls -l | sed '/codehere//g'
but I have no idea how can this filtering be ...
4
votes
1
answer
1k
views
How do I determine file type in Linux?
I'm editing the LS_COLORS environment variable. dircolors lists the default colors for different file types. The file types are denoted as follows:
bd = (BLOCK, BLK) Block device (buffered) special ...
4
votes
1
answer
9k
views
Using alias to change ls to ls-l changes(or disables) the colors of ls output
I've used alias to change ls to ls -l, but the colours change to the normal font of the terminal (also tried ls -l before the alias command and the colours appeared fine).
What is wrong?
Thank you
4
votes
3
answers
3k
views
How to view list of files in Google Drive?
When I list directory components with
$ ls /run/user/1000/gvfs/google-drive:host=gmail.com,user=address
1BzrSykm6X7BBm09yZ7Qcsj_5lL1dMtrN 1p55c8zr6M617qoFU8BopppxaLh0qJTd8
...
4
votes
3
answers
5k
views
create a list of files located in multiple directories
I have a set of data files (*.all) located in different folders
Documents/rawdata/Geob1005/1.all, 2.all, 3.all,...,n.all
Documents/rawdata/Geob1006/A.all, B.all, C.all,...,Z.all and so on......
3
votes
2
answers
348
views
Use read line to iterate over variables
I have the following files:
$ ls *.png | egrep -i "am|pm"
output-0 11.42.30 AM.png
output-0 5.10.12 PM.png
....
I want to remove them but get this error:
$ ls *.png | egrep -i "am|pm" | while read ...
3
votes
3
answers
7k
views
Why does the ls command show deleted files?
When I type ls in the terminal, it shows the files that are present as well as the files that I have deleted. How can I see the current files only, and why does ls keep a record of deleted files?
ls ...
3
votes
2
answers
3k
views
Ubuntu commands aren't working
My Ubuntu seems a bit weird. cd and mkdir work fine, but instructions other than ls and rm do not. I'm not sure what the problem is. Isn't there another way to initialize this path? I have solved the ...
3
votes
1
answer
794
views
Font has been changed
why has the font of my terminal been changed?
3
votes
2
answers
758
views
"ls" with one-digit pattern gives me strange results
I'm running Ubuntu as VM in VMWare Fusion on MacPro:
ayakovlev@ubuntu:~$ uname -a
Linux ubuntu 3.11.10.3 #1 SMP Thu Mar 6 15:31:54 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
The command below outputs ...
3
votes
3
answers
12k
views
folder not shown when being created by command line
I have an issue when I am creating a folder by command line. I create it by typing:
mkdir TEST
and it does not appear on the graphical desktop view. But if I type the command "ls" in the Terminal I ...
3
votes
1
answer
1k
views
run ls but skip first 3 files
Let's say ls -t returns:
1
2
3
4
5
6
How can I skip the first 3 results? So the result is only:
4
5
6
I am aware I can run ls -t | head -3 but that will simply take the first 3 lines, but I need to ...
3
votes
2
answers
3k
views
How to list all files in a hard disk with 'find'?
I'd like to list all the files in HDD including size, last modified date and absolute path.
idea format :
[file size] [last modified date] [absolute path] [ filename]
I tried:
ls -lhR | awk -v ...
3
votes
3
answers
2k
views
How can I exclude . and .. when listing hidden items? [duplicate]
ls -d .* lists only hidden "items" (files & directories). (I think) technically it lists every item beginning with ., which includes the current . and above .. directories.
I also know that ls -A ...
3
votes
1
answer
8k
views
Name of first file in directory obtained in optimal way
Ordinary when I want to show name of first file from directory I type:
ls raw/all | head -n 1
But it takes long time when in directory there any many files
Eg for dir with near to 900 k files we ...
3
votes
2
answers
6k
views
Getting file name in hex or base64
Due to a question on Software Recommendations, I thought I could implement a program that parses the output of ls -l and displays the files in an Explorer like style. This approach was suggested on ...
3
votes
1
answer
3k
views
Recursive directory listing of /proc
I'm trying to obtain a recursive directory listing of my filesystem using the command
$ ls -alRc
from root directory.
Everything is running fine except the /proc directory listing, which results ...
3
votes
1
answer
1k
views
How to set to Black background
Ver: Ubuntu 21.04
In order to change the color scheme, I have set as follows in my .bashrc;
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;96;40m\]\w\[\033[00m\]\$ '
setterm -term linux -back ...
3
votes
1
answer
354
views
broke my 'ls' command (and few more)
This is how my ls command looks like now in htop:
Also, when I try to run ls (or gimp or libreoffice) I get running stegsolve app that I can't reinstall (even found stegsolve binaries).
$ cat /etc/os-...
3
votes
3
answers
3k
views
Is it possible to rename files selected by ls?
I have some files I downloaded recently and I want to name. It is possible to do something like:
rename 's/ /_/g' $(ls -t | head -n5)
Actually, I would like to rename last downloaded 5 files.
...
3
votes
1
answer
384
views
Real time file sizes?
In order to take a look at the sizes of my VM disk images, I tried ls -lh (as it was suggested here). And here is what it returned:
leo@ubuntu:~$ sudo ls -lh /var/lib/libvirt/images
total 65G
-rw-----...
3
votes
1
answer
981
views
ls output not compact anymore
I wanted to ask about the ls command in lubuntu 15.10. Now there is a new line for every entry. I know from other distributions that there is also an output style where ls outputs the content of ...
3
votes
1
answer
602
views
Directory permission
I am running 12.04 x64 server on ext4 disk. There are two user groups 'A' and 'B'. For a specific directory, I would like to give its all permissions to user group 'A'. Also I would like to give only '...
3
votes
2
answers
4k
views
`ls` with wildcard with subdirectories
When I execute a command ls *, it will show
files in the current directory
directories in the current directories
files and directories in the directories in the current directories.
When I do use ...
3
votes
1
answer
908
views
Display all of the files where the extension starts with a certain letter using ls command
How do I display all files where its extension start with a certain letter using ls command?
I tried doing ls d* but that display all files starting with letter d, not extension starting with letter ...
2
votes
4
answers
3k
views
ls command: Show time only (in iso-format)
I found a way to show the date in iso-format: How to make ls produce ISO 8601 format
Now I want to show only the time, not the columns before:
ls --time-style=long-iso -l
drwxr-xr-x 11 foo foo ...
2
votes
2
answers
2k
views
ls vs. ls -C difference
commands ls and ls -C seem to produce the same results - display by columns.
Is there any difference?
2
votes
1
answer
3k
views
display the filenames with 4 or more characters using ls
How to display the filenames with 4 or more characters using the ls command
2
votes
4
answers
1k
views
how can I List files in order
I had an 18GB file I needed to download on a less than great Internet connection. Torrenting wasn't an option. So I busted up the file into 100 segments, and eventually, all of it downloaded. Now I ...
2
votes
2
answers
169
views
ls -d not doing what I'm told it should
Ubuntu 14.04 LTS
Straight machine, no dual boot or anything.
I am in ~/scratch
I want a list of directories only.
tree -dL 1
Got it!
man ls says:
-d List directories only instead of their ...
2
votes
1
answer
4k
views
ls system command not showing terminal colors
I've just been fooling around with some code in C, an example of a really basic program is as follows which just, obviously, lists the directories using the ls system command.
#include <stdio.h>...
2
votes
2
answers
39k
views
terminal ls command not showing all files
I'm familiarizing myself with the terminal, and trying to use the ls command is the directory /usr/bin.
Unfortunately, it doesn't show me everything in the folder, the terminal cuts it off.
How ...
2
votes
1
answer
498
views
Why does 'echo *' give different results than 'ls *'?
For example, if you are in home directory and type ls *, you will have all the directories listed, and below the name of the listed directory, the files that it contains. On the other hand, if you ...
2
votes
3
answers
25k
views
Using the ls command on an Ubuntu 14.04.10 server to explore my files
Very new to Linux, but I thought I understood file exploration from the command line.
The problem:
I can't figure out how to navigate my files or directories, the console isn't displaying any ...
2
votes
2
answers
3k
views
How to make locate output look like `ll` or `ls -la` but nicer?
The locate command output is a little bland:
$ time locate etc/profile
/etc/profile
/etc/profile.d
/etc/profile.d/appmenu-qt5.sh
/etc/profile.d/apps-bin-path.sh
/etc/profile.d/bash_completion.sh
/etc/...
2
votes
2
answers
379
views
ls list files with multiple sizes
In the case we have some files with different sizes: for example one files smaller than 1 Mb and others bigger than 1 MB for example.
If I use ls -l --block-size=M it will show all files with less ...
2
votes
2
answers
5k
views
Why won't ls display output in multiple columns, for some directories?
The ls command and the ntfs file systems have been discussed quite widely for the colours and how to tweak them using the dircolors option. However there seems more to it, which I have started to ...
2
votes
2
answers
13k
views
print contents of a directory structure (filesystem) to CSV on the command line
How can I catalog the contents of a filesystem to a CSV file? This is particularly useful for removable media.
I've found a couple links that point in this direction:
AskUbuntu.com: listing files in ...
2
votes
2
answers
891
views
use output from alias command as filename to open in vi
I set up an alias this morning to help finding the latest log file in a directory. My alias looks like
alias latest="ls -lat | grep ^- | awk '{print \$8}' | head -1"
In my research so far this ...
2
votes
3
answers
788
views
How to remove all files with a pattern except the recently created file
How to remove all files with a pattern except the recently created file
ls -l
total 655748
-rw-r--r-- 1 jetty jetty 120579643 May 10 19:59 2023_05_10.jetty.log
-rw-r--r-- 1 jetty jetty 115205809 May ...
2
votes
1
answer
591
views
How to disable ls colors on ntfs-mounted partitions only? [duplicate]
I love ls colors and do not want to disable them everywhere, but the ls colors are useless on ntfs-mounted (and probably other similar file systems - like exfat) partitions, because all files there ...
2
votes
1
answer
465
views
how to delete all but X last items from find
I want to find some dirs and delete all but the 10 latest dirs.
I can find . -maxdepth 1 -type d -name "XXX*" | xargs rm -rf but that would remove all of them.
I can't use head / tail because I don'...