The ls command lists the contents of a directory.

learn more… | top users | synonyms

2
votes
1answer
93 views

Different output of `find | xargs ls` for the same command on different Ubuntu versions

I have two Ubuntu installations: A: 14.04.3 LTS (GNU/Linux 3.13.0-77-generic x86_64) B: 14.04.2 LTS (GNU/Linux 3.13.0-61-generic x86_64) I'm running the following command: find . -name "nosuch....
-1
votes
1answer
49 views

wildcard usage for a directory displaying filenames in linux?

so one of the questions i have been working on is to display the contents of a directory files by using its wildcards do display specific contents, in this case aim using ls and the portion that I got ...
1
vote
1answer
51 views

What does @ in front of a directory name imply?

On my Synology NAS, when I do ls on my volume, I see that a few directories a leading @ in their names. A few also have a trailing @. What does this imply? Examples: @optware @autoupdate
2
votes
2answers
83 views

Sorting ls output where files end in numbers [duplicate]

Here is the output of my normal ls command: f1 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f2 f20 f3 f4 f5 f6 f7 f8 f9 So I have 20 files. I need them displayed as : f1 f2 f3 f4 ...
0
votes
1answer
75 views

Size of a character/block file

Why is the size of a character or block file given as comma separated? crw-rw-rw-. 1 root root 1, 3 Mar 8 10:15 /dev/null brw-rw----. 1 root disk 8, 1 Mar 8 10:15 /dev/sda1 Size of a file is ...
12
votes
5answers
967 views

How to list all files in a directory with absolute paths

I need a file (preferably a .list file) which contains the absolute path of every file in a directory. Example dir1: file1.txt file2.txt file3.txt listOfFiles.list: /Users/haddad/dir1/file1....
0
votes
4answers
62 views

use ls > filelist and change file list content to file list

I need to use the ls > filelist and, however when is use "cat filelist" it displays all the content in the filelist with filelist as one of the names in it, but i need to change it "* * * File List ...
4
votes
1answer
139 views

Why does “ls” sporadically output only “.” in the root directory of an external drive?

In the root directory of my USB flash drive, sometimes when I run ls, the output is normal and it lists the files. At other times, the output is simply one line: $ ls . If I try ls -la at one of ...
0
votes
2answers
353 views

Meaning of “l” in “lrwxr-xr-x”? [duplicate]

According to this website: http://ss64.com/bash/ls.html The first letter indicates the file type: f means file and d means directory. But in my case I've an l. What's the meaning of this l? In ...
1
vote
2answers
122 views

List files in current directory, prefix numerically

I'm trying to learn bash and I'm trying to list the files I have in a folder using a bash script from a.sh, like this: 1: a.sh 2: b.sh 3: c.sh I've looked at ls and find commands, but they don't ...
0
votes
1answer
82 views

find comand with -exec ls produces a different output

I am trying to determine which files will be touched based on their modified date. My directory is a top a list of perhaps several levels of subdirectories. From a terminal window I run this command: ...
1
vote
1answer
202 views

Show column headers with “ls” command

Does the ls command have any functionality to show the column headers for decoding what the columns are? I'm aware of the portion of support text that describes the columns in info ls
1
vote
2answers
389 views

How do get ls to list directories with a trailing forward-slash?

My shell is bash. How can I get the output of ls to show directories with a trailing forward-slash? When I do ls in tcsh it gives the desired output. How can I get this to occur in bash without ...
-1
votes
1answer
51 views

List just the permissions of a file [duplicate]

I want to know how to just check for the permission of a file. I know ls -l yourfile will show you it but I just need the nine permission letters. Thanks
0
votes
0answers
36 views

Sorting results from ls [duplicate]

I was wondering if there was a way to sort through ls results on the command line. Sometimes I use ls to get the exact name of the folder or file I want to use in a command. So it would be nice if ...
2
votes
2answers
91 views

List PDF files with missing metadata

I have had a few tasks where I needed to make reports on file changes on directories from different servers and have managed to make the reports using simple Unix commands. I used: ls -R -lT /...
3
votes
7answers
185 views

Find directories excluding ending bracket ')'

I'm trying to list all video directories (not files) which don't end in a year e.g. (2015) and more specifically which don't have a year listed, therefore don't end in a closing bracket ). How can I ...
1
vote
1answer
73 views

Help creating a bash shell script based around the ls command [closed]

I'm trying to create a bash shell script that will take an input directory and give me the name and size (with units) within. I'm a bit new to shell scripts, so I've been able to build the script to ...
0
votes
2answers
99 views

bash shell loop through directory listing contents and executability

I'm currently working on a homework assignment and I need to take a given directory path and from that list the files and directories in it. While also including if it's executable or not. I'm also ...
1
vote
7answers
608 views

Matching n letter filename with ls

I am using the ls command in bash, trying to find all files or directory of length n. Let's say n=5 My command is: ls ????? But this would also include characters that are non letters such as ...
1
vote
2answers
184 views

Confused about the behavior of asterisk in ls command

On Centos and Debian I tried this. Does the * with the ls command imply recursive search? If I start to type a dir name and hit tab I see this: # ls /etc/rc<tab> rc0.d/ rc1.d/ rc2.d/ ...
0
votes
1answer
96 views

List file in sub directory with certain permission

So basically I need to list files in sub directory which has all permission for user and group but not other. Basically rwxrwx--- All I got is: ls -d */* to show the sub directories but now how ...
0
votes
2answers
69 views

List files in your home directory [duplicate]

Im having trouble figuring out that, if I'm in let say the directory /home/test/test2 but I want to find the number of files in the /home directory, how would I do it. I know how to do it if it was ...
0
votes
2answers
57 views

File sort by time issue

I have a requirement to identify sequence gap in a set of files. Sequence starts at FILENAME_0001 and ends at FILENAME_9999. After this the sequence is restarted from 0001. To implement a proper ...
1
vote
2answers
73 views

How to order several options of a command (ls)?

Why doesn't ls behave the same after exchanging the order of options -l and -f? $ ls -l -f 0821131236.jpg 0823130821.jpg $ ls -f -l total 33176 -rw-rw-r-- 1 t t 364186 Jan 6 16:06 ...
0
votes
1answer
51 views

Listing files with a certain extension

I'm suppose to write a command that would list all files that end in .tx with an optional t at the end. So far all I got is listing the files that end in .tx which is: ls *.tx Now my problem is ...
1
vote
2answers
195 views

using ls in bash

I have some files like this: a.10 a.15 a.20 a.30 a.40 a.50 if I want to do a same work for all of them I can use for data in `ls a*| sort -n` If I want to do same work one by one. I can use: ...
3
votes
2answers
50 views

Strange discrepancy of file sizes from ls

I've been using ls -sh to check file sizes ever since 1997 or so, but today something strange happened: ninja@vm:foo$ ls -sh total 98M 1,0M app 64M app_fake_signed.sbp 800K loader 804K ...
3
votes
1answer
68 views

Change dir colour in bash output

Under Mac OSX, I am trying to change the dir colour when ls outputs in the bash shell. So I placed this line at the end of my .bashrc file and reloaded. LS_COLORS=$LS_COLORS:'di=0;32:' ; export ...
13
votes
5answers
370 views

How can I find the first missing directory in a long path?

Imagine I have a path that doesn't exist: $ ls /foo/bar/baz/hello/world ls: cannot access /foo/bar/baz/hello/world: No such file or directory But let's say /foo/bar does exist. Is there a quick way ...
2
votes
5answers
586 views

ls | grep works doesn't work with ls --color

I'm trying to list all hidden dirs with the following command ls -lhAF1 | grep -E '^d.*[0-9]{2}:[0-9]{2} \.' which works perfectly fine Explanation for Regex: I'm trying to get all rows that ...
58
votes
4answers
4k views

Why is 'ls' suddenly wrapping items with spaces in single quotes?

I just noticed that on one of my machines (running Debian Sid) whenever I type ls any file name with spaces has single quotes surrounding it. I immediately checked my aliases, only to find them ...
11
votes
2answers
447 views

Why does `watch` make `ls /tmp` list contents of $HOME?

I'm trying to watch number of files in my /tmp/ directory. For this I thought this command would work: watch sh -c 'ls /tmp/|wc -l' But it appears to work as if ls had no arguments. Namely, I'm in ~...
1
vote
3answers
252 views

How to exclude the output file from ls output

Let's say I have these files on desktop: aaa.jpg bbb.jpg I want to list these two jpg's and output them to a .txt file: #!/bin/bash cd ~/Desktop ls -1 > all.txt With this code the all....
1
vote
1answer
87 views

ls -lu does not give last access time

The manpage of ls says: -u with -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time but that doesn't seem to work: test@...
1
vote
2answers
187 views

Full file date (without GNU utilities)

I am trying to obtain the full date (created or modified) of a particular file for passing to another program. I have tried variations of options with the ls command but none provide a full date for ...
1
vote
2answers
40 views

files per directory in a single line

I have following directories: Sample1 Sample2 Each of it contains multiple subfolders like Sample1/R1/ Sample1/R2/ Sample1/R3/ Sample2/R1/ Sample2/R2/ Sample2/R3/ Which further contains ...
0
votes
1answer
42 views

my home directory appears in my download directory

In my Downloads folder when I run ls I see the home directory, and I don't know why, I want to remove it but I am afraid to remove my home folder. Can anyone tell me how I can just remove the home ...
1
vote
1answer
91 views

udev creates the right rules, but rights disappear as soon as I try to access files via C++

I'm facing a really strange problem using udev. As I already explained here I'm trying to access some folders/files as a no root user Here are my udev rules for the gpio folder: KERNEL=="gpio*", ...
0
votes
1answer
80 views

Strange directories in /home

There are some strange directories appearing in /home (so far, maybe in other locations too). These directories do not show up in ls but do with bash's tab autocomplete, when doing things like cd. ...
1
vote
2answers
123 views

Listing line number of results in `find` and `ls` [duplicate]

Is it possible with either find or ls to see, in a list of results, if any given entry is the nth result, what n is? So, for example, pretend ls -l returns: total 0 -rw-rw---- 1 bigdog bigdog 0 Jan ...
2
votes
1answer
58 views

size of directory reported by ls [duplicate]

I understand the size reported by ls corresponds with number of inodes inside the directory, not their actual size. I have noticed peculiar behavior, when displaying directory size with ls. Here is ...
1
vote
4answers
184 views

How to show only hidden directories, and then find hidden files seperately

I'm trying to list all the hidden files in a directory, but not other directories, and I am trying to do this using only ls and grep ls -a | egrep "^\." This is what I have so far, but the problem ...
0
votes
1answer
58 views

ls default sorting inconsistent

Why does adding identical characters to the end of filenames change the sort order as shown below? In any sane string comparison method I would expect the comparison of 2 strings to not differ if the ...
6
votes
3answers
286 views

Flatten the output of a recursive directory listing

Is there a way to list out all the files within a directory tree in a single list, sorted by modification time on Linux? ls -Rlt lists out files recursively, but they are grouped under different ...
2
votes
1answer
84 views

ls & dircolors - differentiate between symlink to directory and symlink to regular file

Is it possible to have the colors for symlinks-to-directories be colored differently than other symlinks? I know I can do: Link target to get the symlinks to take the color settings of their ...
0
votes
0answers
12 views

What are the possible file type characters `ls -l` can make, and what do they all mean? [duplicate]

Running ls -l, I can get a lot of different prefixes for the permissions, for example: lrwxr-xr-x drwxr-xr-x prw-r--r-- These are permission from a link, a directory, and a pipe respectively. What ...
1
vote
0answers
56 views

change ls color on OpenWrt

I am not able to change the color of dir entries for ls command (dark blu is a very annoying color to read) on my OpenWrt device. I've added the line LS_COLORS=$LS_COLORS:'di=0;37:' ; export ...
1
vote
4answers
559 views

How to sort files by part of the filename?

Given the files below: ABC38388.SC01.StatueGrade_MKP ABC38388.SC02.Statue_GKP DEF38389.SC03.Statue_HKP XYZ38390.SC00.Statue_WKP How can I list them all based on the SC value, like this: XYZ38390....
10
votes
6answers
8k views

How do I pipe ls to grep, and delete the files filtered by grep?

I wanted to delete some package in my home file, but the filename was too long (google-chrome-stable_current_i386.deb). So, I decided to use the command ls|grep chrome|rm to pipe the files to grep to ...