The ls command lists the contents of a directory.

learn more… | top users | synonyms

0
votes
2answers
22 views

Changing the color of only one directory in ls

Is there a way to change the color of only one of the listed directories in the ls command? I have researched the LS_COLORS variable, but this doesn't solve the issue because you cannot list specific ...
1
vote
1answer
45 views

Make an IF condition out of result we get from remote server

I need to check for files availability in remote server, and based on the files availability i need to make an if condition. I have tried the below commands in a shell script to list the files in the ...
0
votes
4answers
97 views

Is there a “ls” replacement that can handle wildcards?

I just learned that ls cannot handle wildcards (ls '*' does not work) and therefore the shell does it before ls is invoked. So the behaviour of ls may be considered as logically for people working 20 ...
1
vote
2answers
68 views

Copy files that are created today without FIND command and SFTP to another server

I have a directory with 'n' number of files in it. I am trying to write a shell script which will list only the files created on the particular day the script is running, and will use sftp to move the ...
12
votes
3answers
646 views

How can I make “ls” show dotfiles first while staying case-insensitive?

Create the following files in a directory. $ touch .a .b a b A B 你好嗎 My default ls order ignores the presence of leading dots, intermingling them with the other files. $ ls -Al total 0 -rw-r--r-- ...
-1
votes
4answers
90 views

What will ls -l | wc -l command display?

Will: ls -l|wc -l Display the number of devices too? (Including files and directories)
2
votes
1answer
46 views

Permission denied when using -exec {} ls with find command

When run following command it gives me permission denied message for all the files. find /data/code/ -name "*.jar" -exec {} ls \; find: `/data/code/project/shared/build/thirdparty/log4j-1.2.8/...
0
votes
2answers
29 views

Listing numbered files using wildcard sequence with predefined range

I have a folder of numbered data files. I am trying to incrementally extract a predefined range of files. The range of files that I am looking for is predefined in two variables, ns and ne, which ...
0
votes
3answers
49 views

Seeing mode of file without listing all files

I want to see the mode of file/folder foo, in the form drwxrwxrwx. I would normally do ls -lah | grep foo, but in this case the folder had so many subfolders, that it took a long time for ls to run. ...
0
votes
3answers
42 views

Command to print the number of *.pdf files in a chosen directory [duplicate]

I am currently not on a Linux machine. Would the following command produce my wanted result? ls | grep ".pdf" | wc
1
vote
2answers
34 views

Tolerant file system for a failed automount

(I am running openSUSE 13.2) My current setup I have an external backup drive which I mount at boot with the following line in my /etc/fstab: /dev/mapper/cr_backup /backup ext4 comment=...
11
votes
15answers
2k views

'ls -1' : how to list filenames without extension

ls -1 lists my elements like so: foo.png bar.png foobar.png ... I want it listed without the .png like so: foo bar foobar ... (the dir only contains .png files) Can somebody tell me how to use ...
1
vote
1answer
56 views

passing ls variable to grep when doing a file search only works inside directory

I am running a command that I use to find the most recent file in a folder then grep the contents for a matching pattern. Here is the command flow that shows the problem I am having. root@backup /]# ...
0
votes
4answers
83 views

Is there a way to show the permissions for a file without using `ls`

That's all - just wondering if there's other way to find out the permissions for a file without doing a ls -l to see the string of values there. As far as I know, there's no show option in chmod.
0
votes
0answers
43 views

permission denied, cannot list files within a folder

I have a folder like: drwx--xrwx 9 user group 4096 May 1 11:17 160429_ST-E00110_0195_AHMFVNCCXX However my user other can't do ls: -bash-4.1$ ls 160429_ST-E00110_0195_AHMFVNCCXX ls: cannot open ...
0
votes
2answers
37 views

Doing ls -l /dev [duplicate]

When experimenting with the ls -l command I noticed that in the /dev folder ls -l was sometimes printing something like this in the first column : crw-rw----+ What is this "+"? What does it mean? ...
1
vote
1answer
61 views

Terminal color usage does not stay

I was wondering if any of you knew why doesn't my terminal keep displaying stuff colored, after I use the command ls -l -a --color=always I would like it to stay colored, so when the next time I type ...
0
votes
2answers
50 views

List Most Recent File per Sub-Folder

I have a File structure of : FOLDER/SUB_FOLDER/Text_File I have over 1k+ FOLDER and each FOLDER has at least 2 different SUB_FOLDER with each SUB_FOLDER their own Text_File. I'm trying to ...
2
votes
2answers
39 views

Instead of using ls, how does it make work with `find`?

I have this command: ls -Ra | grep -cve/ -e'^\.*$' and I would like to do exactly the same with find I tried this find . -name "^\.*$" -o -print | wc -l but the problem is, if I create new file ...
0
votes
2answers
37 views

Universal abstraction of ls

Specs OS: OS X; Client: Terminal; Shells: sh, bash Problem I'm writing a shell script that adds a layer of abstraction to the ls command. I want to make it "unbreakable", so I started by figuring ...
-2
votes
3answers
36 views

listing files with pattern with starting and ending

I want to list all files in a directory that start with 'abc' and end with '.zip' I'm trying to use ls. The directory has a lot of zip files starting with abc<date> and xvz<date>. I only ...
5
votes
5answers
535 views

Is it possible to run ls or find and pipe it through stat?

Is there a way to run ls or find to get the list of files within a directory and then run stat to get all of the specific information (i.e. File Group, File Name, File Owner, File Size (displayed in K,...
-1
votes
1answer
49 views

What does this command do, exactly?

I have this command, but I don't get what it does. ls -Ra | grep -cve/ -e'^\.*$' And how can I do the same with 'find' command.
0
votes
1answer
53 views

List hidden files only (not just dot files) using an ls alias

I would like to use an ls alias (like l.) to output a colored list, consisting of only hidden files & directories, whether or not they begin with a dot. Any suggestions? Example of desired ...
5
votes
5answers
88 views

execute command on a defined range of directories

Is it possible to 'partition' a directory listing - say in to blocks of some number, to perform different actions on each 'range'? For example, lets say I have the following directories inside ...
2
votes
2answers
76 views

“ls” command stuck trying to list a stale mount point. How do you kill/stop it?

When working with remote filesystems such as sshfs or smbfs, it is command that they become stale due to network problems. To check if the mount is stale or not, I usually use the command ls to see if ...
1
vote
1answer
47 views

Set ls -l time format

I would like for all my ls commands that display a date, such as ls -l, to print the date column in a format of my choosing. Currently, I manually set this every time with --time-style. Is there any ...
0
votes
3answers
1k views

find -exec ls -lR {} \; returns every item twice

Background: I'm currently writing an archiving script, which creates gzipped tarballs from some folders and their contents. It should be able to synchronize the gzipped archives with the sources ...
2
votes
1answer
26 views

make ls gray out files that end with tilde (`~`) using `LS_COLOR`

Problem: I am trying to modify LS_COLORS to gray out all files ending with the tilde character. Question: Can anybody spot my mistake? Here is what I did: # write dircolors file: dircolors -p > ...
2
votes
2answers
41 views

List all the files in ending with several file extensions?

If I want files ending with .fas I know I can do the following with ls command : ls -l /users/jenna/bio/*.fas and this lists out all the files ending with .fas. But how can I get files ending with ...
3
votes
4answers
172 views

How do I extract a long listing field?

I want to extract the access day of a file in a shell script. I tried by writing the following script but it doesn't work. When I echo accessday, the output is "staff". file=$1 accessday=$(ls -lu $...
1
vote
1answer
77 views

What is the number at the top for the results for ls -l? [duplicate]

When you type in ls -l, there is a number on the first line labeled "total 22037"? What does this number mean? I am attempting to write my own version of ls -l( in C), and how do I get this value or ...
2
votes
5answers
161 views

Have the ls command behave differently based on the number of entries

Is it possible to have the ls command behave differently based on the number of directory entries that may be listed? If I just use ls (with no modifying options, but I can specify directories or ...
0
votes
0answers
27 views

File and folder size using ls and du [duplicate]

I created a folder and copied a 992 byte jpg file in it. Then I created a hard and soft links for the file. The hard link is the same size of the file and the soft link is 8 bytes. Now when I checked ...
-9
votes
1answer
52 views

Unix “ls” command? [closed]

Can someone explain to me what are all the options available with the -la flags for the ls command ? I have read the man pages, but still not sure.
6
votes
3answers
467 views

How do I get `ls -l` output for a link recursively until reached the original file?

Let me give an example (it's just an example taken from here): $ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-...
3
votes
2answers
61 views

Quoted filenames with spaces in ls output on OSX

The problem I don't want to see filenames quoted when they contain spaces. Example On OSX I see this when running ls: > ls -l total 0 drwxr-xr-x 2 mafro staff 68 Mar 16 09:02 'dir with spaces' ...
3
votes
1answer
42 views

Argument list too long when running ls -d “$PWD”/* command

I'm trying to execute ls -d "$PWD"/* > formmlFileList43k.list But I get the following error: bash: /bin/ls: Argument list too long I've read using a pipe won't have such limitation, how can I ...
2
votes
1answer
85 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
45 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
48 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
82 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
61 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
961 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
61 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
128 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
207 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
111 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
69 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
106 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