The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
3answers
77 views

How use an if statement to change the output message

When i run this command it still outputs the same message when nothing is in the waste bin directory, how could I get the command to output a different message when there are no files in the bin? ...
1
vote
2answers
509 views

File Permissions Sticky&User Execution

After the website of a client has been hacked, I found some files with the following permissions set What exactly S and T stands for? Also, which one is the command to set them with those ...
2
votes
1answer
99 views

ls after cd in tcsh?

I cannot seem to find an answer to this question. In my .bash_profile I have this line: cd() { builtin cd "$@"; ll; } which executes ll every time I change directories. I would like this ...
1
vote
1answer
87 views

sshfs: permission denied when trying to access specific folder

I can access to my specific folder like this: ssh -YX xxx@xxxxxx.xxx.xxxx.xx cd ../the/folder/I/want or with an absolute path ssh -YX xxx@xxxxxx.xxx.xxxx.xx cd /the/absolute/path/to/the/...
2
votes
1answer
399 views

passing variables from 'ls' to 'tar' via 'xargs'

I am trying to do something like ls -t | head -n 3 | xargs -I {} tar -cf t.tar {} to archive the 3 last modified files but it ends up running the tar command separately for each of the files and at ...
1
vote
1answer
577 views

ls: No such file or directory error

I am writing a very basic shell for my school. Even thought commands like "pwd" or "date" works when i try "ls" it shows me that "ls: No such file or directory error" The code of my shell is bellow:...
0
votes
1answer
86 views

How do I do a long listing of files and only show those that are a certain size?

I need to show a long listing of files in a directory but only those that are a certain size in bytes. Can someone tell me how to do this?
3
votes
5answers
545 views

Search files for a string and if found check if a file with paired name exists in the same directory

I have many different files with the same ending .ft1 that may or may not contain one specific word special. For the files that contain this word, I want to check whether another file with a different ...
0
votes
1answer
36 views

Using `tree`, how do I output files before subdirectories?

I tried to combine --dirsfirst and -r, but directories still show up on top, only in reverse alphabetical order. It seems like -r is applied first, which is also indicated by the man pages. Any other ...
0
votes
0answers
28 views

How can binary names in command prompt be colored

I recently saw in a presentation that the typed in commands that matched something in /bin /sbin /... were colored green. It looked nice and felt more structured. How can this be achieved with ...
4
votes
1answer
2k views

Pass colors from ls through pipe to awk 'print' statement

This is a follow-up to my question from yesterday, Show sum of file sizes in directory listing. Thanks to Zero Piraeus and a point in the right direction by Mauritz Hansen, I now have function dir(...
1
vote
0answers
33 views

`ls\` logs out of terminal session?

Like many, I have an alias ll=ls -l[.]+ set. A moment ago, I typed ll and then accidentally hit \ on the way to return. I hit return again to finish the command (on the continued line prompt), ...
0
votes
0answers
11 views

List extensions of files and their amount [duplicate]

I want to list file extensions and the number of files for this extensions at once. I tried this: ls -R | grep -Eo "\..+" | sort -u|wc -l but it only count the number of file extensions, without wc -l ...
0
votes
3answers
113 views

How to list all files *.html bigger than {size} excluding some {*parts*}

I need a command to list files. But I have three problems: I want files ending with .HTML and .HTM If any file has parts like: google docs or form in the name, I want to exclude it. I want just ...
0
votes
2answers
331 views

Fix LS Colors for directories with 777 permission? [duplicate]

When I run ls on a folder with directories that have a 777 permission, the ls colors are purple text with a green background, which is unreadable: What can I do to make this more pleasant to look ...
4
votes
2answers
9k views

Basic commands in Unix not working i.e: -bash: ls: No such file or directory

I'm new to Unix and in the process of installing a program for my dissertation I must have played with the PATH for the basic Unix commands such as ls. Every time I type ls and the directory name I ...
1
vote
1answer
71 views

How to make ls warning me about parent directory is symlink

I just found a scenario which i (or someone new to linux) might accidentally rm file because user thought it's duplicated file. Let's say i have this two binary files: [xiaobai@xiaobai note]$ ls -...
2
votes
1answer
945 views

How to remove all but last 10 files [duplicate]

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 +...
5
votes
2answers
609 views

How do I get the total size of everything in a directory in one line? [duplicate]

I know I can use du -h to output the total size of a directory. But when it contains other subdirectories, the output would be something like: du -h /root/test . . . . 24K /root/test/1 64K /root/...
55
votes
7answers
21k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
1
vote
1answer
121 views

Why do these two find-commands give different results?

I wanted to see all files modified within the last 10 days and who owned them, so I entered the following to give me an idea how many results would be returned; find . -maxdepth 1 -mtime -10 I then ...
1
vote
2answers
2k views

How to change the output color of the ls command in terminal in OS X and iTerm2?

I know that a similar question has been asked in: How to colorize output of ls ? although I didn't really understand the answer and couldn't really make it work. However, I have tried something ...
3
votes
5answers
603 views

Look if a folder has some files with certain extensions

Suppose I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and see if they have any ".pdf" files. Could some one please ...
3
votes
1answer
126 views

OS X: Can `ls` show broken symlinks?

When in Linux, I enjoy having \ls -l --color=auto show broken symlinks with red text for the name of the symlink and blinking text for the missing linkee. But in OS X, \ls -lG (the closest thing I ...
0
votes
2answers
108 views

What does “ls --dired - l” or “ls -D -l” actually print?

ls --dired -l prints all dir and files along with some number followed by //DIRED// ***66 69 122 131 ....*** //DIRED-OPTIONS// --quoting-style=literal What do these numbers in bold mean? --dired ...
3
votes
1answer
52 views

How to list files named like XXXmmyy.dat in natural chronological order?

I use a Mac OS X (V10.9.5) and work in the X11 window, and I often need to deal with thousands of files named like XXXmmyy.dat, where XXX is a 3-letter acronym of a place, mm is the 2-digit month, and ...
1
vote
1answer
33 views

Only color files according to file types? [duplicate]

When using ls to list files in a directory, the files are colored according to their access permissions. Is it possible to color the files only according to their file types (e.g. a regular file, a ...
1
vote
1answer
237 views

ls -l without file permissions

How can I use ls while using -l (long listing) without showing the file permissions? Right now I have the following alias for ls: alias ls='ls -lhaG --color=auto' I have found a solution close to ...
48
votes
3answers
45k views

What causes this green background in ls output?

There are two directories shown by 'ls'. Normally directories anywhere are blue on black background. But the first one is blue on green and impossible to read. Why is this? How to make it blue on ...
1
vote
2answers
229 views

Changing colors used by `ls` does not work in Emacs “Shell” mode

I followed http://unix.stackexchange.com/a/94508/674 to change the colors used by ls. This works in bash. When I open a buffer of "Shell" mode in Emacs (M-x shell), the change doesn't work. I wonder ...
10
votes
4answers
700 views

List files that match a pattern but ignore files that match another pattern?

Let's say I have a directory with files a1, a2, a3, b1, b2, b3. I only want to match files that start with a but don't contain 3. I tried ls -I "*3" *a* but it returns a1 a2 a3, even though I don't ...
8
votes
6answers
27k views

List files larger than {size} sorted by date

I want to solve the problem 'list the top 10 most recent files in the current directory over 20MB'. With ls I can do: ls -Shal |head to get top 10 largest files, and: ls -halt |head to get top ...
8
votes
5answers
4k views

Why does “ls -all” show year or time?

If you issue ls -all command some files or directories have the year and some have the time? Why do some show the year while others show the time? Is the time representative of the time the file was ...
29
votes
5answers
10k views

Understanding UNIX 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
2answers
75 views

Is there a way to list files before mounting a disk partition

Suppose there are several partitions in my computer. I'm not sure where is the folder I have to access. Usually what I do is mount all the partitions first and then search one by one. Is there a way ...
0
votes
5answers
212 views

List only the count of all files/directories for the directory tree of present directory

I want to list the number of directories under each subdirectory tree of the present directory. As there are too many directories, I can't go into individual directories and check. I would like to ...
1
vote
0answers
26 views

LS_COLORS mixing matching criteria, e.g. file extension and hardlink

I'm wondering if there is a way to keep the characteristic color of the extension type in ls --color=auto as well as underlining the file if it is a hard link. For instance, if I do LS_COLORS="*....
0
votes
1answer
494 views

get list of files which are unique

I have a directory in which files are created as abc.sh.ID.datetimestamp.id.log In the filename abc.sh, the ID is always the same (there are 1000's of .sh's and ID's combination in the environment). ...
1
vote
2answers
82 views

Finding a file which has “info” in its title

By using the ls command I can list the names of all the files in the directory I am working with. However, how do I list all of the files in the directory which have contained in their title info? So ...
3
votes
3answers
171 views

Why size reporting for directories is different than other files?

I was wondering why an empty directory occupied 4096 bytes of space and I have seen this question. It is stated that space is allocated in blocks and hence, the size of a new directory is 4096 bytes. ...
4
votes
3answers
2k views

ZSH: `ls *(.)` lists regular files only but `ls *(/)` does not list directories only

I'm not sure I am using ZSH's globbing correctly, but I thought ls *(/) would just list the dirctories under pwd, but it doesn't, it recursively lists all files under every directory under pwd (I got ...
4
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 #...
0
votes
0answers
143 views

Cannot see files present on server when connecting via Filezilla / SFTP

I am not able to see the files present on the server using Filezilla ftp client. I am using SFTP connection. I am able to connect to the server. I can see only the directories but not the files. ...
3
votes
1answer
25 views

How can you group symlinks with directories in `ls` output but tell the difference?

In ls output, I'd like to group symlinks that point to directories along with the rest of the directories, but still have a way of telling that it's a symlink either with color or an appended symbol. ...
0
votes
2answers
247 views

Script that list file names by first letter bash type [closed]

I need a script that takes input from the user which specifies the first letter of the file names to be displayed, so that only file names starting with the letter specified are listed. I only need to ...
-3
votes
2answers
409 views

List all files that end in “ball” using ls command [closed]

I am trying to use ls command to find specific files that Have 4 letters in front of the word "ball" Must have the ending word "ball" I have been trying to use ls *ball but this shows words with 4 ...
1
vote
2answers
93 views

How to extend the ls command by a custom column

I wonder if it is possible to modify the ls -l command by a custom column. For example, I would like this column to contain for each file, say, the first line of $(CustomCommand FILE).
4
votes
5answers
641 views

How to list the n'th youngest file (without parsing ls!)

So I know parsing ls is bad!. Today I found this nugget: FILENAME=`ls -t $READ_FOLDER | head -1` So I believe originally this was designed to grab the newest filename, I actually now want to adapt ...
45
votes
2answers
110k views

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

With the ls command, is it possible to show only the files created after a specific date, hour...? I'm asking it because I have a directory with thousand of files. I want so see all files that were ...
10
votes
6answers
732 views

How do I display the nth result of an ls command?

I used this command to display the first result of files in my directory. ls | head -n 1 My simple question is, how can I modify this command to display say the nth result? Thanks!