The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
1answer
938 views

Difference in file listing for SSH and SFTP [closed]

I have SSH access to a server and I have never bothered to use SFTP until now. I transferred a file using FileZilla to the server. However, the weird thing is that the file doesn't show up when I ...
8
votes
2answers
2k views

Testing LS_COLORS in zsh

A few years ago I found an interesting code snippet that prints each type of file in its corresponding color according to the colors set up in LS_COLORS. Unfortunately, I can't remember the link ...
5
votes
5answers
8k 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 ...
27
votes
2answers
22k views

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
0
votes
3answers
5k views

How to copy files from linux to windows using winscp from a folder which contains millions of files

I need to copy files from a linux machine to a windows machine where the only ports which can be open are for SSH (22). I can connect to the linux machine using WinSCP but the problem is once I try to ...
2
votes
2answers
1k 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 ...
9
votes
3answers
2k views

Why is sorting files by access time not working?

I tried to use command ls --time=atime it was working in one directory but wasn't working in another directory. I opened certain files in vim, evince and other applications but after the command file ...
0
votes
3answers
4k views

Human-readable ls output under AIX?

How can I get human-readable ls output under AIX? There is no -h parameter
2
votes
1answer
2k views

Enable line breaks when assigning multi line outputs to var in bash

I'm using the following very basic shell script I copied off the net to list the contents of my database backup folder and mail them regularily: MYSQLLIST=$(ls -lhG /var/backups/mysql/daily/) ...
1
vote
1answer
662 views

How can I make ls show information about the directory specified only, not info about its sub-files or folder contents?

Say I have folder "foo" residing, the home directory. I want to get some info of it, owner, group, permissions, etc... I then do this to try to get the information: cd ~ ls -l foo Of course it now ...
4
votes
2answers
976 views

Tell if a folder/file is hidden in Mac OS X

I know you can set or unset the hidden flag of a folder/file by doing chflags hidden foo.txt and chflags nohidden foo.txt. But is there anyway of telling whether the folder/file is currently hidden ...
4
votes
2answers
5k views

How to list ALL directories according to their size? [without including the parent directory]

I have a bunch of random folders, some of them are hidden (beginning with a period). I want to list all of them, sorted by their sizes. I have something on the lines of this in mind: ls -d -1 -a */ ...
7
votes
1answer
505 views

Using dircolors, how do I change the color of my subversion folders

Below is a sample of my dircolors file, I want subversion folders (.svn) to be colored, but i guess the extension section only applies to file names. How do i set colors for directories with ...
4
votes
4answers
1k views

file $(ls /usr/bin/* | grep zip) command gives me errors. What's wrong?

I'm a total noob when it comes to unix/linux commands and I decided to read a book. I've reached a chapter where they try to explain how to pass the output of commands as expansions to the shell. ...
2
votes
2answers
205 views

Move one file at a time based from specific number in the files

Based from this question, The HTML files date format has been changed. All of the HTML files have the date such like below: 20110730dateishere dateishere is intentionally added by me in the files, ...
1
vote
3answers
1k views

Ls with spaces + variables

I want to do something like this, but it doesn't save the variable after the piping ends: fs=( ) echo ${fs[@]} ls -A1 | while read f do echo ${fs[@]} fs+=( "$f" ) echo ${fs[@]} done echo ...
9
votes
1answer
17k views

How can I assign the result 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"; ...
10
votes
6answers
32k views

How to list files without directories, and filter by name (ls options)

I have a directory called uploads. It contains a bunch of files, plus a few subdirectories which in turn contain files. Is there a way I can (in one step) do the following: List ONLY the files in ...
2
votes
1answer
2k views

Why can't list file/directory relative to .. from a symbolic link directory (No such file or directory)?

I have a /usr/tomcat6/logs directory linked to /var/log/tomcat6. When I changed directory to /usr/tomcat6/logs and try to ls files using a relative pathname ../conf/Catalina/localhost, a No such file ...
7
votes
2answers
936 views

Is there a correct way to list the subdirectories of the current directory?

I can find the subdirectories of a directory by ls -d -- */ or ls -l | grep "^d" but both of these seem indirect, and I would imagine that there would be a standard way to find just the ...
5
votes
1answer
3k views

ls: how do I list directories sorted by timestamps of the files it contains

How do I list directories by their access time in the sense that some new files/directories are created (say, directories containing the most recently created files).
3
votes
1answer
971 views

ls -a not showing folder “system”, but echo * shows it

When I create a folder named system in my home folder, or in /tmp (can't try other locations as I am not root, but owner confirmed same problem even on root), ls -a will not show it. Also tried ...
9
votes
4answers
2k views

What is the “directory order” of files in a directory (used by `ls -U`)?

According to the man page for ls, ls -U means: do not sort; list entries in directory order. What does "directory order" mean, and how is it determined? The following test (executed on an ...
10
votes
6answers
4k views

What does the “number” in the owner field of files signify in linux?

I copied many files to my new linux host. I see that all files have the owner and group both set to 515. What does that mean?
24
votes
1answer
2k views

Why does “ls *” take so much longer than “ls”?

I have a couple of files in a directory: $ ls | wc -l 9376 Can anybody explain why there is such a huge time difference in using ls * and ls? $ time ls > /dev/null real 0m0.118s user ...
6
votes
3answers
2k views

How do i open all files that are the result of a ls command?

I'd like to open all text files that are the result of a ls command using a text editor. How do i do this?
3
votes
2answers
494 views

Total in `ls -l`

When I run ls -l, the following is displayed: >: ls -l total 320 -rw-r--r-- 1 foo staff 633 5 Apr 13:23 A.class -rw-r--r-- 1 foo staff 296 5 Apr 13:24 A.java ... What does the ...
17
votes
11answers
2k views

Linux - command to list files (except ls)

Imagine you were working on a system and someone accidentally deleted the ls command (/bin/ls). How could you get a list of the files in the current directory? Try it. I tried many ...
13
votes
4answers
20k views

Why is Debian's root shell colorless?

Are there any security concerns? What is the best way to enable it?
3
votes
3answers
1k views

Really strange FAT32 file listing problem

I'm mounting a FAT32 drive on my NAS (which has a USB port), and hitting a strange issue when I use the ls command on the drive root: ls: cannot access ???²é?u.g: Input/output error ls: cannot ...
19
votes
2answers
7k views

Output from ls has newlines but displays on a single line. Why?

I think I may be overlooking a relatively fundamental point regarding shell. Output from the ls command by default separates output with newlines, but the shell displays the output on a single line. ...
15
votes
2answers
52k 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 ...
5
votes
6answers
3k views

Compare files that are in directory 1 but not directory 2?

I'm having trouble with a bash script I want to make I know ls will list files that are in a directory but I want it to list directories that are in directory1 but NOT in directory2, and then list ...
14
votes
4answers
11k views

last time file opened

Is it possible to get the time when file was opened last time and sort all files in a directory by those times?
15
votes
3answers
12k views

Find the owner of a directory or file, but only return that and nothing else

I am looking for a command that will return the owner of a directory and only that--such as a regex parsing the ls -lat command or something similar? I want to use the result in another script.
3
votes
1answer
220 views

ls pagination on MontaVista with BusyBox

I'm logged into an IP Phone running MontaVista with a very stripped down BusyBox binary (by stripped down, I mean the OEM has removed almost all of its functionality, except the basics like cat, ls ...
11
votes
3answers
9k views

What is the Linux equivalent of DOS “dir /s /b filename”?

List all files/dirs in or below the current directory that match 'filename'.
4
votes
2answers
2k views

Scrolling through ls output without a mouse

In some directories there are quite a few files. When I use ls the output is more than my terminal can handle. Typically I just use one of the following: ls | less ls | more depending on my mood. ...
2
votes
2answers
294 views

Is it possible to change the spacing between files using ls

I'm fairly new to unix and I was wondering if there's some attribute of ls that I can use to change the spacing between the files. Currently I've aliased my ls to output ls -G, so that I have colored ...
4
votes
2answers
950 views

How can I search for a file with fixed name length using ls?

In a directory, I have files like lazer_100506 lazer_100707 lazer_091211 lazer_110103 lazer_100406_temp lazer_100622#delete etc How can I get a listing of only the first four files? $ ls ...
4
votes
1answer
288 views

Set ls color listings based on regex instead of globbing

Is it possible to set regex patterns for color matching in the LS_COLORS variable? So instead of just *.jpg=38;5;220 Can I do \.(jpg|gif)=38;5;220 That's just an example, I'd like to get more ...
14
votes
5answers
6k views

What is the difference between ls and l?

I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is ...
19
votes
3answers
3k views

ls command: what does the first line mean?

When I do ls -l I get this: calico@A000505:~/Documentos$ ls -l total 2020 -rwxr-xr-x 1 calico calico 8559 2010-11-16 11:12 a.out -rwxrw-rw- 1 smt smt 2050138 2010-10-14 10:40 Java2.pdf ...
5
votes
3answers
4k views

list full path of file without tying it from relative relative path

I could do this root@server [/home/user/public_html]# ls /home/user/public_html/.htaccess but I'd like to do this ls --switch .htaccess /home/user/public_html/.htaccess is it possible?
2
votes
1answer
2k views

Find the disk-space usage of a directory and all it's files [duplicate]

Possible Duplicate: How to know the size of a directory? If I run ls -lh then any given directory is just shown as 4.0K. How can I can make it consider the files the directory refers to ...
1
vote
0answers
141 views

How can I list only the directories present in a directory using ls? [duplicate]

Possible Duplicate: Is there any option with 'ls' command that I see only the directories? I have a directory with a lot of files but only a few directories. To get a list of only ...
2
votes
1answer
995 views

LS_COLORS settings for specific types of files

I'm trying to set up my color scheme for ls, and I'm having trouble finding information about exactly what parameters I have to work with, or where those come from. And especially setting colors for ...
4
votes
2answers
2k views

ls'ing through an entire directory tree to produce one pipeable list of files

This might have been answered already. But I wasn't able to find it. I have: directory directory/subdirectory/subdirectoryofsubdirectory ...
4
votes
1answer
4k views

+ or @ mark after running 'ls -al'

In Mac OS X, run 'ls -al' gives me something like this. drwxrwxrwx+ 4 smcho staff 136 May 5 09:18 Public drwxr-xr-x+ 6 smcho staff 204 Feb 1 2010 Sites drwxrwxrwx 9 smcho staff ...
26
votes
5answers
7k views

Is there any option with 'ls' command that I see only the directories?

Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that? EDIT: I'm using Mac OS X, and ls -d gives me . even though ...