Results 1 to 5 of 5

Thread: Universal Recursive wildcard

  1. #1
    Join Date
    Jan 2005
    Location
    Utah, USA
    Beans
    61
    Distro
    Xubuntu 10.04 Lucid Lynx

    Universal Recursive wildcard

    I remember seeing a bash string that was, effectively, a wildcard for every file and directory at the current level (including hidden files). I think there was a ** and a // and of course a *.* in there somewhere.... Anyone care to unveil the mystery?
    IBM T42

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Universal Recursive wildcard

    If the dotglob option is enabled, then * matches any file exept the hard
    links to the current and parent directories (. and ..):

    Code:
    shopt -s dotglob
    echo *
    shopt -u dotglob

  3. #3
    Join Date
    Jan 2005
    Location
    Utah, USA
    Beans
    61
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Universal Recursive wildcard

    I failed to mention (but included it in the thread title) that it did this recursively. I don't think it needed any special options enabled.
    IBM T42

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Universal Recursive wildcard

    As far as I know, in bash, you have to enable both globstar and dotglob to be able to match any file recursively with a single pattern:
    Code:
    shopt -s globstar dotglob
    echo **/*
    See:
    Code:
    man bash | less +2/"Pathname Expansion"
    Code:
    man bash | less +2/"Pattern Matching"
    and
    http://mywiki.wooledge.org/BashGuide/Patterns

    I don't know much about other shells, but in zsh:
    Code:
    echo **/{.,}*
    seams to work with the default/recommended settings.
    Last edited by sisco311; January 15th, 2011 at 02:02 AM.

  5. #5
    Join Date
    Jan 2005
    Location
    Utah, USA
    Beans
    61
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Universal Recursive wildcard

    Ok, perhaps I was seeing this done in another shell. Thanks!
    IBM T42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •