ls

Quick ls command

I've got to get a directory listing that contains about 2 million files, but when I do an "ls" command on it nothing comes back. I've waited 3 hours. I've tried "ls | tee directory.txt", but that seems to hang forever. I assume the server is doing a lot of inode sorting. Is there any way to speed up the ls command to just get a directory...

Maximum number of inodes in a directory?

Is there a maximum number of inodes in a single directory? I have a directory of 2 million+ files and can't get an the ls command to work against that directory. So now I'm wondering if I've exceeded a limit on inodes in Linux. Is there a limit before a 2^64 numerical limit? ...

List files recursively in linux with path relative to the current directory

This is similar to this question, but I want to include the path relative to the current directory in unix. If can do the following: ls -LR | grep .txt But it doesn't include the full paths. For example, I have the follow dir structure: test1/file.txt test2/file1.txt test2/file2.txt The code above will return: file.txt file1.txt f...

How do you determine what bash ls colours mean?

When you perform ls in a bash shell, sometimes there are colours to indicate different resource types, and you can enable/control this with the --color argument. But neither the man page nor Google is providing an answer to the question: What do these colours indicate by default, and how do I display what the current system uses? UP...

C# command-line arguments and ls

I'm using MSYS to get some semblance of a sane scriptable shell on Windows :). Now I'm writing a console application, written in C#, that accepts a number of arguments and presents those as options to the user in a dialog box. The actual options correspond to file names, that I'm retrieving with ls. However, trouble appears when I have...

Unable to get the size of a directory by ls

I run the command unsuccessfully to get the size of directories (files inside belong to the size of a directory) ls -lSrh I get only kilobits for the size of directories while their content is more than that. How can you list the size of directories including their content in the number by ls? ...

Unable to put colors for LS by LS_OPTIONS

I find out that you can have the following for Grep in .bashrc # puts colors for all grep commands export GREP_OPTIONS='--color=auto' I did not manage to get the similar command for LS_OPTIONS to work. Is there any other way than the following to give colors for your ls -command? alias ls='ls -Gh' ...

Preserve ls colouring after grep'ing

If I do $ ls -l --color=always I get a list of files inside the directory with some nice colouring for different file types etc.. Now, I want to be able to pipe the coloured output of ls through grep to filter out some files I don't need. The key is that I still want to preserve the colouring after the grep filter. $ ls -l --color=...

`ls` exit status

EDIT: nothing to see here!!! 127 return means the command wasn't found - had to give an absolute path to the command for some reason :/ (I didn't delete in case someone else has this problem) Is there a reference of return statuses for common Linux functions like ls? (it doesn't seem to be in the man pages, at least for ls). If not, can...

XML Output in Java -- what's with DOMImplementationLS ?

I just had to write the following stupid class to avoid going insane: import java.io.OutputStream; import org.w3c.dom.Document; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; public final class XMLSerializer { pu...

Portable way to achieve ls' -v flag (i.e. sort by version)?

I'm working on a some build scripts that I'd like to depend on only standardized features. I need to sort some files by version. Say the files are bar-1.{0,2,3} bar-11.{0,2,3}. By default, ls gives me: bar-1_0 bar-11_0 bar-11_2 bar-11_3 bar-1_2 bar-1_3 Getting what I want is easy using 'ls -v': bar-1_0 bar-1_2 bar-1_3 bar-11_0 bar-...

BASH: Find highest numbered filename in a directory where names start with digits (ls, sed)

I have a directory with files that look like this: 001_something.php 002_something_else.php 004_xyz.php 005_do_good_to_others.php I ultimately want to create a new, empty PHP file whose name starts with the next number in the series. LIST=`exec ls $MY_DIR | sed 's/\([0-9]\+\).*/\1/g' | tr '\n' ' '` The preceding code gives ...

Using grep and ls in ftp client?

How could I use grep and ls in ftp client... I mean if I want to find some specific file I could use, ls -l | grep pattern thanks. jcyang. ...

ls command: how can I get a recursive full-path listing, one line per file?

How can I get ls to spit out a flat list of recursive one-per-line paths? For example, I just want a flat listing of files with their full paths: /home/dreftymac/. /home/dreftymac/foo.txt /home/dreftymac/bar.txt /home/dreftymac/stackoverflow /home/dreftymac/stackoverflow/alpha.txt /home/dreftymac/stackoverflow/bravo.txt /home/dreftymac...

Find missing numbers in continuous filenames (advanced ls & find)

Let's say I have a script that generates incrementing folder names over time (100, 101, 102, 103, 104, etc...). These folders are synced between machines and there is a chance of creation failure for any given folder on system 2. System 1 is always in sync: 100/ 101/ 102/ 103/ 104/ etc... System 2 may have errors: 100/ 102/ 103/ etc......

shell script ls globbing question

Hi I am trying to use: ls -la *randomString* in my shell script to list out all the files and directories that contain a substring: "randomString" everything works fine except when it encounter a directories that matches the substring, when it does it will give me something like this: (lets say the directory name was "TTrandomStringTT...

BASH file attribute gymnastics: How do I easily get a file with full paths and privileges?

Dear Masters of The Command Line, I have a directory tree for which I want to generate a file that contains on two entries per line: full path for each file and the corresponding privileges of said file. For example, one line might contain: /v1.6.0.24/lib/mylib.jar -r-xr-xr-x The best way to generate the left hand column there appe...

Is it a bug in Linux time() function or Linux OS calls?

Dear All, I wrote a small program, that creates files at an interval of 1 minute. But the time at which the file is created and last written and the last modification time of the file as shown by ls command differs by 1 second. The code and the output is presented below. please let me know where could be the bug? root@new:/home/sriniva...

Improved technique to store a filename in a variable?

Greetings, I need to store the filename of a log into a variable so my script can perform some checks on the daily log files. These logs always have a different name because they have a timestamp in the name. Currently I'm using a hodge podged method that pipes an ls command to sed, sort, cut, and tail in order to get the name out. C...

ls color schemes

What's your favorite color scheme for ls in bash? There's lots of vim color schemes out there, but I'm having trouble finding any for ls. Does anyone know any good websites with sample ls color schemes? If you've made a custom one, attach a screenshot, along with the line to put in ~/.bash_profile. export LSCOLORS=DxGxcxdxCxegedabag...