The ls command lists the contents of a directory.

learn more… | top users | synonyms

0
votes
2answers
40 views

'+' and 's' in permission strings

If the ls -l command gives me a permission string like rwsr-s--x What does the 's' mean? The only sources I found mention that it can be present sometimes but do not elaborate. What does a '+' ...
0
votes
1answer
12 views

see newest release last (YML release files with the same timestamp from Git)

I pull from Git *yml files with "$packagename-$release.yml". The highest number is the most recent release. I wish to have the listening with latest release last. Correct sort order ...
0
votes
1answer
60 views

What's the -alhF flag in ls?

What is the -alhF flag in ls? I can't find it in the man page.
0
votes
3answers
111 views

Concat 1000 files within a directory [closed]

I know we can concat files by cat file [file] [[file] ...] > joined-file. I have directory which contains lots of files. I want to concat all of them. I want to concat 1000 files irrespective of ...
4
votes
4answers
184 views

How to show only the last k columns in ls -l?

I like to restrict the columns shown in ls -l command, by eliminating the first 4 columns. ls -lh shows: drwxr-sr-x 20 gamma alpha 4.0K May 22 13:18 Desktop drwxr-sr-x 3 gamma alpha 22 Oct 6 ...
1
vote
1answer
50 views

LS_COLORS for 256-color terminal

I thought ls colors are defined as <file_type>=[<bg(40-47)>];<font_spec(0:5)>;<font_color(30-37)> but, I recently found this where there are more colors and colors are ...
1
vote
1answer
23 views

Screen bind key requires extra Enter (RET) key

I was playing around with GNU Screen's configuration and put the following configuration in ~/.screenrc: bind l eval 'exec ls' So, now when I type C-a l, it runs ls under the current directory. ...
1
vote
1answer
55 views

Assigning ls output to a variable gives unexpected behavior

I was writing a script to clean a text file from a directory (I know,it's a bad idea but I really need it) and I wrote this: #!/bin/bash var=$(ls -p /direcotry/to/file | grep -v /) truncate -s 0 $var ...
1
vote
0answers
129 views

How to understand the security context in “ls -Z”?

After referring "man ls", it shows "ls -Z" can display the security context: -Z, --context Display security context so it fits on most displays. Displays only mode, user, group, security ...
0
votes
1answer
49 views

`ls / | wc -l` tells more lines than `ls /` shows [duplicate]

ls / outputs two lines. $ ls / bin cdrom etc initrd.img lib lost+found mnt proc run share sys usr vmlinuz boot dev home initrd.img.old lib64 media opt root sbin ...
2
votes
2answers
61 views

Efficient search of unique owners of files and directories

I would like to view the unique owners of all the files and directories underneath a certain directory. I have tried: ls -ltR <dir-path> | grep -P '^[d|\-]' | awk '{print $3}' | sort | uniq ...
0
votes
1answer
74 views

Solaris: How to run a system command on top of awk and combine all output in a single line

Have this peculiar requirement to print files in a given directory in the below mentioned format filename1 <type of file> owner group filename2 <type of file> owner ...
-1
votes
1answer
28 views

Advice with How to Return the # of Files found within a folder [duplicate]

Create a script to ask a user for the name of a folder and have the script return the number of files found within the folder. If folder doesn't exist, display error message to the screen I've gotten ...
0
votes
2answers
86 views

find and list -R returning different number of files

I'm trying to create an array variable with a list of files to use in a small script, needing the full path to the file. Looking around I tried something like this: find /path/ -t f | grep ...
6
votes
2answers
373 views

What defines “ll” in Fedora?

In Fedora, instead of typing ls -l, you can type ll. What causes this behavior? I've installed a new Debian system that does not appear to have this functionality. They're both running Bash. I can ...
6
votes
2answers
259 views

Exclude one directory in `ls` matching pattern

I'm trying to ls dirs that have .png files inside (no need for recursiveness, though it would be extra useful), exept one. Exlude one directory i.e. ls */*.png works fine. ls (^one)*/*.png ...
0
votes
4answers
206 views

Foreach loop for ls output

I am trying to process some files in directory using foreach loop for ls output: IFS=$'\n' for i in $(ls -1Atu); do echo "$i" done At first time i thought it works, but when i created file ...
2
votes
2answers
495 views

ls pattern matching

I know that [] is working in ls pattern matching: $ ls foo.c foo.h $ ls foo.[ch] foo.c foo.h but I cannot find where this is documented. I would like to know the syntax that would match these: ...
1
vote
5answers
181 views

Difference between 'ls -ltr abc*' and 'find ./ -name abc*' command? [duplicate]

To search a file in a directory, I found two commands as below: ls -ltr initialfilename* find ./ -name initialfilename* Sometime, first command gives me the search result but sometime I used to ...
0
votes
3answers
475 views

How do I copy the latest file from one directory to another?

I have 3 zip files in a directory. I want to copy the most recent version to a backup directory. My code works fine for .sh and other files, but not for .zip. Is there something else I have to do? ...
-1
votes
2answers
67 views

Linux Bash Scripting Issue with Wildcard

I'm having issues with what I imagine should be a simple bash command I'm basically just trying to loop through a bunch of files and get there names `ls ./*.sql` # list all files ...
1
vote
1answer
52 views

How to distinguish between output of numerous similar commands

Say I am issuing ls -la in a directory that has hundreds if not thousands of files, then changing to another directions and issuing ls -la. I then need to scroll up to see what files are in the most ...
1
vote
2answers
80 views

How to list only the last line of each directory?

I learned thanks to you, how to display only the last line of a listing,e.g. ls -ltr | sed '$!d' Now I thought, how to combine it with the find command, in order to repeat this onto each directory ...
1
vote
3answers
64 views

How to display only the last line of a listing ?

Supposed I make a listing and sort the files by its temporal attribute: ls -ltr -rwxrwxrwx 1 bla bla 4096 Feb 01 20:10 foo1 -rwxrwxrwx 1 bla bla 4096 Feb 01 20:12 foo2 . . . -rwxrwxrwx 1 bla bla ...
1
vote
1answer
151 views

Why are files and directories colored in different ways? [duplicate]

On Ubuntu 14.04, in bash under gnome terminal, Why are files especially directories colored in different ways? The green colors hide the text to me (How about to you?). Is it done by terminal or ...
1
vote
2answers
105 views

ls or find option to exclude binary files

How can I list only files that aren't compiled code in the current directory? I'm reviewing the custom scripts and code on several HPUX and Linux servers before transferring them to a newer system. ...
0
votes
1answer
186 views

du and ls commands reporting wrong directory size

I'm used to the du command. I often use it with -h option. I report the result in a text file which I use to track space consumers. But I was wondered today to see a directory being reported as using ...
3
votes
2answers
173 views

How to list files on terminal so that we can see the file types such executable, ascii etc?

I have been trying to list files in directory using ls and passing it different options. Does it have the ability to list types of files as well ? I want to know which ones are executable , ...
1
vote
1answer
120 views

What does the @ symbol mean on filenames [duplicate]

When I do an ls in the /proc/PID directory a number of @ symbols show up next to the file names. Normally I would consider this to mean extended attributes but when I do the long form of ls they do ...
1
vote
1answer
67 views

BASH: looping through ls [duplicate]

I'm having trouble with this piece of code: 22 for filename in "$( ls "$1" | grep ".*\.flac$" )"; do 23 file_path="$1${filename}" 24 ffmpeg -i "${file_path}" -f ...
0
votes
1answer
85 views

*ls* font differences between files and folders with “--color” option

I have recently switched to urxvt from xterm for better unicode support and it does much better as to the font fallback. However I find an interesting issue: names of files and folders are rendered ...
2
votes
2answers
244 views

How to remove all but last 10 files

I accumulate sequentially named files as the result of an automated process, and I would like to keep only the last 10 around. I tried this, which had the effect of deleting everything: ls -r | more ...
6
votes
1answer
4k views

No such file or directory but I can see it!

I'm trying to run a python script, on a headless Raspberry PI using winSCP and get the following error message: Command '"./areadetect_movie_21.py"' failed with return code 127 and error message ...
1
vote
2answers
215 views

“ls” in directory outputs “No such file or directory” for some files

I cd to a directory that has a large number of files, 40,948 to be exact. When I issue ls it takes a long time and before the command finally prints the results to the screen it tells me "ls: cannot ...
2
votes
1answer
156 views

Question marks instead of national letters in console

I have Netgear Stora MS2000 (which uses a modified version of Red Hat) and have strange font issues while connecting by SSH. Note that this occurs both when connecting by PuTTY from Windows and by ...
0
votes
0answers
41 views

getting ? in permissions when running ll/ls command

I am trying to remove a folder and I am getting rm: cannot remove ‘...' when running the ll command I am getting : > ll ./folder/ ls: cannot access ./folder: Input/output error total 64 ...
1
vote
3answers
223 views

What is the meaning of ls -d ?

I entered the man page of ls, the entry for the -d option is as follows: -d, --directory list directory entries instead of contents, and do not derefer‐ ence ...
0
votes
2answers
173 views

Solaris 11.2 extended permissions shown by ls

I have a file that shows up as having extended file permissions. ls -V /usr/share/X11/app-defaults/XScreenSaver rwx------ 1 root root 53 Dec 2 21:52 ...
4
votes
1answer
254 views

Can the command completion for `cd` be modfiied to only show directories and ignore files?

When I am in a directory in bash, and I press cd Space Tab, it shows everything in the directory as a possibility. (Show all 1000 possibilities?) This is really cumbersome when I am in a directory ...
2
votes
4answers
193 views

get file size and line count at the same time

I'm looking for a way to list all files in a directory, with both their size, and a line count. Right now I'm using stat -c \"%s %n\" /directory/* to get file names and sizes, and I know I can use ...
1
vote
1answer
21 views

How to display metainformation for different kinds of time of a file ?

As far as I know each name within a path, e.g. /name1/name2/name3, is allocated to one inode. This inode is a collection of meta information for each name (file or directory). Some of these ...
0
votes
2answers
137 views

bash permissions - unknown problem

So strangely enough I have the following problem in a directory inside a script: #!/usr/bin/env bash MAIN_DIR=/home/ec2-user/dir/ LAST_DIR=$(ls -d -t ${MAIN_DIR}*/ | head -1) When I run it I get: ...
12
votes
5answers
2k views

How do I get the size of a directory on the command line?

I tried to obtain the size of a folder (containing folders and sub folders) by using the ls command with option l. It seems to work for files (ls -l file name), but if I try to get the size of a ...
12
votes
3answers
750 views

No colored output in less for the ls command

If I run ls I get colored output which I find pretty handy for quickly getting a glance of the kind of file. When I try to pipe it to less even with the -r and -R flags the coloring always get lost. I ...
1
vote
1answer
136 views

What are all possible letters for Unix file permissions?

I'm trying to write a regular expression to match Unix file permissions returned by ls -l command. Here I found that all possible letters for the first field are d,c,l,p,s,b,D. Now, what are all ...
2
votes
2answers
579 views

Using find to list all files under certain directory

I'm trying to use a single line command that will find every directory (or sub-directory) named bin and will then print a list of all the files under it, but will not also list the directory names ...
0
votes
1answer
212 views

What does the option -C achieve in ls output?

In the man pages it says: -C list entries by columns However, I really cannot notice any difference between the output of ls or ls -C, could someone explain this to me?
-1
votes
2answers
214 views

How do I get a list of all directories and files with absolute paths each line ?

Using ls -R / i get every file and directory listed that exists, but not in the desired format. What do I need to write on the command line in order to get a list in such a format, that every line ...
6
votes
1answer
237 views

stat: print time in “long-iso” format

For my script, I would like to have stat command to print time in a nice, human friendly, way: 2015-02-04 00:48:31. ls calls this format long-iso and it can be used like this: $ ls -lA ...
0
votes
4answers
64 views

What is the command to find the read/write permissions for a single file?

I know that ls -l lists the permissions of every file in a directory but what is the command if I want to see the permissions of just a specific file?