Re: Bash globbing files only?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29Jan2007 21:29, Jacques B. <jjrboucher@xxxxxxxxx> wrote:
| >Try this:
| >
| >  set -x
| >  ls [^.]*/
| >  ls -d [^.]*/
| >  ls -d */
| >
| >It would be interesting to see what the differences are, if any.
| 
| Thanks for the tip & additional info.  The results of the above after
| doing unalias ls and set -x:
| 
| (directory names neutered slightly to protect the youngs)
| 
| ls [^.]*/
| + ls 'My son'\''s Passion/' Desktop/ download/ 'Final Material/'
| ftools/ images/ 'Linux Forensic Documents/' LPIC/ 'Other son -
| Profession/' Photos/ PicasaDocuments/ Presentations/ scripts/ thumb/
| 
| followed by the content of each of the above folders

So, as expected then, yes?

| The other two yield identical results, being:
| 
| + ls -d 'My son'\''s Passion/' Desktop/ download/ 'Final Material/'
| ftools/ images/ 'Linux Forensic Documents/' LPIC/ 'Other son -
| Profession/' Photos/ PicasaDocuments/ Presentations/ scripts/ thumb/
| 
| followed by the directory names above.

Good, also as expected.

| I like that trace feature - lets you see how the globbing gets
| expanded.  So we see that the original syntax yields the content of
| the directories, whereas as expected the -d only lists the directory
| names.
| Not to beat a dead horse, but I hate not understanding why something
| works (or doesn't work).  Why is it working on yours but not mine?
| Are you getting the same trace output for the ls [^.]*/ command, but
| without listing the contents of those directories, only the directory
| names?

I get what you get. We have established A) that "*/" and "[^.]*/"
are equivalent and B) that -d prevents burrowing into the directories.
We should have added:

  ls */

to the tests above to try all four permutations.

Does it make sense now?
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Kilimanjaro is a pretty tricky climb. Most of it's up, until you reach the
very, very top, and then it tends to slope away rather sharply.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux