Wednesday, July 16, 2025

Obscure Bash Question

 It has been almost 20 years since I made heavy use of Unix, but I vaguely recall a construct in some shell where you could 

ls {circle*|mkcircle*} 

and have it match every file of those two wildcard matches.  I cannot find that in any reference work.  Was that just an imagined capacity because I wanted it?

3 comments:

  1. If you use the Nemo file manager (it looks like file manager from Windows - is installed by default on Mint, might be on Debian as well) there is a search box. Select the directory you want searched and input a term. It handles all the regular expression stuff for you.

    If you want to DIY/roll your own, then search for "regular expressions" in the docs. If memory serves, it covers all that stuff

    The new interfaces like Cinnamon make Linux look more like Windows or Mac than like the old Unix.

    ReplyDelete
  2. Use a comma instead of a pipe.

    ls {circle*,mkcircle*}

    ReplyDelete
  3. Starting here https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html and also following the Pattern Matching link at the bottom, I think you want 'shopt -s -o extglob' to turn on extended pattern-matching, and then probably *(circle*|mkcircle*), but I don't have access to a bash shell right at the moment to check.

    ReplyDelete