On Sunday 30 September 2007, Florian Philipp wrote:

> Which shell do you use? Bash's default behavior (I don't know whether
> you can change that) is that it doesn't expand * to all files and
> directories but only the nonhidden.
>
> Just try the following:
> ls -l --directory --all ~/*
>
> On my system it only shows my a long lost of all directories and files
> without a dot at the beginning although, strictly speaking, the
> command should show all files, even the hidden ones.

No, it should not (assuming the syntax of your example), unless 
bash "dotglob" option is on. One thing are the options to ls, another is 
how the shell expands wildcard characters.
In your example, the tilde is expanded to the user's home dir 
(eg, /home/user), the asterisk is expanded to all the file and directory 
names under /home/user not starting with ".", so what ls really sees is

ls -l --directory --all /home/user/dir1 /home/user/dir2 /home/user/file1 
/home/user/file2 
etc.

Since you gave the "--directory" (aka "-d") option, and "*" expansion 
does not include names starting with ".", nothing else is printed. 
The "--all" option does not come into play at all here.

A different story would be if you did not use the -d option; then names 
at first level starting with "." still would not have been shown 
(because "*" is expanded by the shell before ls sees the names), but 
directory contents would have been listed including names starting 
with ".", due to the --all option.

Another variation would be not using -d and giving only "~" as pathname 
to ls (ie, not "~/*"). In that case, ls would see just "/home/user" and 
the --all option could do its job at the first level, listing all the 
names, even those starting with ".".

The bash option to have "*" expand to all the names, including those 
starting with ".", is "dotglob" (eg, "shopt -s dotglob). man bash 
explains it all.

> Is it possible that you mean regular expressions and not Bash's
> expansion feature?

This is possible (well, sort of) enabling the "extglob" option in bash.
-- 
[EMAIL PROTECTED] mailing list

Reply via email to