The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
1answer
46 views

Edited sudoers, but `sudo ls` fails

A user has been added with root access in the /etc/sudoers but, it seems that it can not run sudo commands. [root@compute-0-0 ~]# cat /etc/sudoers root ALL=(ALL) ALL hduser ALL=(ALL) ...
0
votes
0answers
20 views

Is there a way to “flag” some directories so that that get a given color when I do ls [duplicate]

My use case is that a few directories on my system are dist'ed on github. Typically the dotfiles directory, some packages I am writing etc... Because their number grows I'd like to flag them when I ...
2
votes
3answers
35 views

How to get last folder (sorted alphabetically in descending order and matching a pattern) using ls/find/etc?

So I have these filesystem structure /my.parent -> my.folder1 -> my-file1.txt -> my.folder2 -> my-file2.txt -> another-folder-here -> another-file.txt Using ...
3
votes
5answers
348 views

When I redirect the output of ls to a file, the filename is included in that file. How can I avoid this?

Observe: $ ls $ ls > list $ cat list list This appears to indicate that when ls is executed that the redirection into file list has already begun and the list file is already created. A fine ...
5
votes
2answers
908 views

“ls $PWD” and “ls .” get different files, strange caching perhaps?

I have a strange problem on my Linux Mint machine (with solid-state drive if that matters). Somehow the machine (on multiple occasions) gets different files, and different content for the same file, ...
0
votes
1answer
26 views

Move files only if filename based regex does not match file in target dir

Best explained by an example: Source dir: file-a-1.txt file-b-1.txt Target dir: file-a-2.txt Expected result: file-a-2.txt file-b-1.txt Move all files from src dir to target dir only if ...
1
vote
2answers
45 views

pipe ls to grep (lines vs. “items”)

Consider the following command: ls dir1 dir2 file1 x1 x2 y2 when this output is piped into e.g. grep each file/directory is processed as an 'item'. ls | grep f file1 So obviously there is a ...
2
votes
2answers
55 views

shopt -s extglob not working as expected

I am trying to recursively change file permissions in a wordpress installation affecting everything below the public_html document root folder, excluding certain folders. I have set extglob on with ...
1
vote
1answer
38 views

What does '-t' do in mv command? Example below

ls -lrt |grep 'Jun 30th' | awk '{print $9}' | xargs mv -t /destinationFolder I'm trying to move files from certain date or pattern or createuser. It doesn't work properly without the -t option. ...
1
vote
1answer
36 views

Colour-coordinate symlinks/softlinks based on where they refer to

Is there any way to colour coordinate symlinks/softlinks based on where they're linked, or maybe by who they 'belong' to (similarly to colouring the output of ls for example)? To give you an example ...
4
votes
1answer
55 views

What's the meaning of a '#' character before owner?

What does the # character preceding the owner name mean? For example: me@server /dir/sub/sub-sub $ ll v* x* -rwxrwxr-x 1 #owner group 1176 Jun 25 2009 vfc.sh -rw-r----- 1 #owner ...
-7
votes
1answer
40 views

meaning of -h in ls command

[root@pdbosl02 daily]# ls -lrth total 12G -rw-r----- 1 oracle dba 3.8G Dec 7 20:43 BKPOSLPRD_jcns9p1f.F_bkp -rw-r----- 1 oracle dba 4.2G Dec 7 20:46 BKPOSLPRD_jdns9p1f.F_bkp -rw-r----- 1 oracle dba ...
0
votes
2answers
23 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
57 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
101 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
89 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
655 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
124 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
50 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
31 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
51 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
43 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
3k 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
71 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
85 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
1answer
58 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
65 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
52 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
40 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
38 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
48 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
545 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
52 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.
1
vote
1answer
56 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
93 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
88 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
65 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
27 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
44 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
198 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
80 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
170 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
69 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
45 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 ...