Skip to content

Instantly share code, notes, and snippets.

@codeforkjeff
Created October 3, 2014 02:36

Revisions

  1. codeforkjeff created this gist Oct 3, 2014.
    21 changes: 21 additions & 0 deletions glob_test.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash
    # run this in a dir with some .zip files

    # note that we do NOT escape glob patterns here
    opts="-iname *.zip"

    # normally, bash will expand *.zip and find will complain about arguments
    echo "find will complain:"
    find $opts
    echo "========================================"

    # prevent bash from expanding glob
    set -f

    echo "find works!"
    # this works
    find $opts
    echo "========================================"

    # back to original globbing behavior for remainder of script...
    set +f