The ls command lists the contents of a directory.

learn more… | top users | synonyms

0
votes
2answers
30 views

Why is there a minor number in /dev for directories such as pts?

This is a part of /dev in CentOS 6.6. What is the meaning of the minor number for directories like ., .. , bsg, block and ... ? drwxr-xr-x. 18 root root 3800 Jul 3 06:00 . dr-xr-xr-x. 21 ...
6
votes
8answers
9k views

Convert ls -l output format to chmod format

Say I have the following output from ls -l: drwxr-xr-x 2 root root 4096 Apr 7 17:21 foo How can I automatically convert this to the format used by chmod? For example: $ echo drwxr-xr-x | ...
0
votes
1answer
40 views

Meaning of chmod 1775

Created a folder "Sample_dir" and analysed its permissions. $ mkdir Sample_dir $ ll Sample_dir/ total 36 drwxrwxr-x 2 user user 4096 Jul 1 19:26 ./ drwx------ 71 user user 28672 Jul 1 19:26 ../ ...
3
votes
1answer
1k views

ls and vim color on SunOS 5.8/Solaris 8

I want to use ls and vim with color on Sunos 5.8 SunOS 5.8 Generic_117350-11 sun4u sparc SUNW,Sun-Blade-2500 I have installed ls (GNU coreutils) 6.9 and vim 7.2 In ~/.cshrc: setenv TERM sun-color ...
1
vote
2answers
121 views

How to use logical OR in find?

In bash shell ls can use a logical OR functionality through (of course I could also do ls name1 name2 but my true examples are more complicated): ls @(name1|name2) Is there a way to do this using ...
26
votes
4answers
40k views

What do the fields in ls -al output mean?

The ls -al command shows the following output; -rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe What are all the fields in the preceding display?
-1
votes
0answers
19 views

What does ls > list do, what does ls >> list do? [duplicate]

I have been asked to explain how and why ls > list and ls >> list are different, unfortunately I don't even know what either of these do :( Also when I typed them into Linux nothing seemed to ...
2
votes
1answer
200 views

sudo ls not showing hidden files on Linux

Today I discovered that sudo ls shows hidden files (that is, those that have names starting with .) on OS X. This surprised me so much that I asked a question about this behaviour, which I still find ...
0
votes
0answers
64 views

Completely hidden directory on ACFS imported via NFS

how is this possible: [root@oda001-d0 .ACFS]# pwd /OVS/Repositories/repo1/.ACFS [root@oda001-d0 .ACFS]# ls -la .. total 148 drwxr-xr-x 8 root root 4096 Jun 23 11:45 . drwxr-xr-x 5 root root 4096 ...
4
votes
1answer
3k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
19
votes
5answers
3k views

Understanding UNIX based permissions and their attributes

I've never really got how chmod worked up until today. I followed a tutorial that explained a big deal to me. For example, I've read that you've got three different permission groups: owner (u) ...
0
votes
1answer
25 views

Find directory names with N occurences of a set of characters

Sorry in advance, I know there are hundreds of posts about find, but I genuinely don't understand what's happening here and haven't been able to find a definitive answer to this question: how to match ...
1
vote
1answer
52 views

change LS_COLORS behaviour

I am trying to modify LS_COLORS behavior. Presently it (say for sh or py), changes color depending on if it is executable or not, as shown here But, I want all my script, executable or not, have ...
11
votes
1answer
809 views

'ls' showing two identical files in a directory

So somehow the command ls seems to be showing me two identical files in a directory. I am certainly not doing something right here. Behold $ ls -Blah /System/Library/LaunchDaemons total 32 ...
0
votes
3answers
40 views

What rights signify when using ls -l? [duplicate]

When I type ls -l and press enter I get a list of files, with details about each file. Next to each file there is permissions and rights for each file. What do they mean? For example: -rw-rw-rw- I ...
0
votes
1answer
35 views

How do I make 'sudo ll' work? [duplicate]

Every once in awhile, I find myself needing to list files in a directory that I don't have execution permission on. So I do a sudo: >sudo ll /opt/mydir [sudo] password for civfan: sudo: ll: ...
1
vote
4answers
266 views

How to use regex to match a pattern which does not have a specific string at the end

How to use a posix bre or a posix ere regex to match a word which does not have bak at the end. I want to do a ls | egrep '<regex>' to find all files which DO NOT have bak at the end of ...
8
votes
4answers
14k views

Difference between ls -l and ll?

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but ...
18
votes
6answers
20k views

Sorting files according to size recursively

how to scan a folder recursively and find the largest files in the folder, and sort them by size. I have tried using ls -R -S but it tends to list the directories as well I need to scan the folders ...
1
vote
1answer
48 views

why grep does not print the entire line? [duplicate]

When I enter ls command I get the below output. -$ ls aNode ANode bNode BNode cNode CNode DUMP file1 hello.txt TEST.txt -$ As seen, above output is one line which has filenames separeted ...
4
votes
1answer
139 views

Permission errors even permissions are wide open

I installed anaconda on our new VM and I can't list it's contents. I can change my directory to .../anaconda/ but when I type ls -l I get: ls: cannot open directory .: Permission denied However, ...
20
votes
9answers
2k views

Find files whose name is 4 characters long

I would like to find files whose name has only 4 characters. Example, there are three files under /tmp: $ ls /tmp txt file linux Output should only show file because it only has 4 characters.
1
vote
2answers
75 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
43 views

How to create a bash script that sees all files in a directory and tells me their size and date of creation?

I'm a beginner in the field of programing/coding. I'm trying to write a simple bash script that will see all files in a directory, and then tell me each file's size and each of their dates of ...
2
votes
5answers
131 views

Get Comma Delimited List of Initials of Items in Directory?

How can I generate a comma-delimited, case-insensitive list of the first characters of the names of the files and directories in a directory, excluding initial "." items, without duplicates? I don't ...
0
votes
1answer
60 views

What does this ls command do? [duplicate]

what does this command do if it was executed in my current working directory that has files in it? ls 2> result I think whatever ls writes will be redirected to the result file? Is that correct and ...
4
votes
2answers
104 views

ls -e option not available in linux

I have shell scripts that run on Solaris UNIX that use the -e option on ls to ensure the same format for all files regardless of their age. This option is not available on Linux. The exact same ...
-1
votes
1answer
50 views

list files in ascending order

I am trying to display file names(with complete path) based on the created timestamp in ascending order. if files exists: display files with complete directory path in asc order. if files do not ...
12
votes
10answers
40k views

Show sum of file sizes in directory listing

The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current ...
24
votes
2answers
75k views

How to get only files created after a date with ls?

With ls command, does it possible to show only file created after a date, hour... I'm asking it because I have a directory with thousand of files. I want files created since yesterday. I use ls ...
1
vote
2answers
38 views

User cannot see directory permissions

I'm working in Ubuntu 3.13. The permissions on a drive are such that the owner can see directories and files with these permissions: drwxrwxr-x 2 michael atlas 4096 Feb 15 12:34 temp2 ...
0
votes
4answers
63 views

Why does my “ls -a-l /home” not work?

Marias-MacBook-Air:~ mariasharapova$ ls -a /home . .. Marias-MacBook-Air:~ mariasharapova$ ls -a-1 /home ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...] ...
3
votes
2answers
152 views

change file size format when using stat

The formatting character %s makes stat print the filesize in bytes # stat -c'%A %h %U %G %s %n' /bin/foo -rw-r--r-- 1 root root 45112 /bin/foo ls can be configured to print the byte size number ...
0
votes
2answers
38 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 '+' ...
12
votes
2answers
36k views

How can I assign the output of a command to a shell variable?

I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; ...
0
votes
1answer
11 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 ...
26
votes
6answers
60k views

How to list all files in the size order

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
17
votes
5answers
23k views

How to match case insensitive patterns with ls?

I would like to list all files matching a certain pattern while ignoring the case. For example, I run the following commands: ls *abc* I need to see all the file that have "abc" as a part of the ...
0
votes
1answer
53 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
94 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 ...
21
votes
8answers
18k views

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort ...
4
votes
4answers
141 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
20 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
16 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. ...
2
votes
4answers
1k views

Find directories that do not contain subdirectories

I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories. I know that I could use ls -alR and recursively parse ...
1
vote
1answer
41 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 ...
3
votes
1answer
3k views

(Why) is it bad to use ls -A to list hidden files?

I want to list every file, including hidden files, in the current directory. I don't want to include the parent (..) and current (.) directory. I found this: how to glob every hidden file except ...
12
votes
6answers
13k views

How do I limit the number of files printed by ls?

Is there a way to limit the quantity of listed files on a ls command? I've seen: ls | head -4 but to get head to be executed I need to wait for ls to finish execution, and with directories with an ...
1
vote
0answers
56 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 ...
-1
votes
2answers
133 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 ...