[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ls features
From: |
James Youngman |
Subject: |
Re: ls features |
Date: |
Fri, 22 Oct 2004 15:00:06 +0100 |
User-agent: |
Mutt/1.3.28i |
On Thu, Oct 21, 2004 at 02:32:38PM -0500, Mike Miller wrote:
> The 'ls' command has many great features/options but case insensitivity is
> not one of them.
Absolutely. Unix filesystems are case sensitive. The "ls" program is
the primary means of identifying files in Unix filesystems.
> Also, things like 'ls *' will fail if the directory listing is too
> long.
No, that's a failure of the "exec" system call, which has limits on
the number of bytes passed as arguments to a command. If the limit on
that is too low for your requirements, you need to do one of the
following :-
1. Use "for f in *; do [whatever]; done
2. Use just "ls" instead of "ls *".
3. Use find and/or xargs
4. Complain to your vendor and persuade them to increase the execve()
argument length limit.
> Other GNU tools such as 'locate' and 'find' can handle case
> insensitivity and larger numbers of files, but neither of those
> programs has the features of 'ls'.
With GNU findutils though, case insensitivity is not the default. To
get case-insensitive behaviour out of the findutils tools you have to
provide special options ("-i" for locate and "-iname" or "-iwholename"
for find).
> While it may be possible to use 'find' with 'ls' to do case
> insensitive directory listings and other nice things, it is not
> convenient.
Unix filesystems aren't case insensitive though either. "ls" is
consistent and that's deliberate. What other nice things did you have
in mind?
> Therefore, I suggest that either a case-insensitivity option be added to
> 'ls,' or that a secondary ls-like command be developed that will allow for
> case insensitivity and listing of large numbers of files. I believe that
> such a program would be widely used.
ls will already list large numbers of files if you don't specify a
wildcard. If you do specify a wildcard, the limit is in your
operating system, not in "ls".
If you want case-insensitive glob matching, which I think from your
statements you do want, just turn on that option in Bash by putting
"shopt -s nocaseglob" in $HOME/.bashrc :-
address@hidden:~$ shopt -u nocaseglob
address@hidden:~$ ls f*o
foo
address@hidden:~$ shopt -s nocaseglob
address@hidden:~$ ls f*o
Foo foo
address@hidden:~$ ls Foo
Foo
address@hidden:~$ ls foo
foo
address@hidden:~$