4 ms·
Really? I thought the shell could only expand globs if it matches files on the local file system?
by lohfu 6y ago
Really? I thought the shell could only expand globs if it matches files on the local file system?
- ses1984 6y agoThoae aren't globs, if you put an asterisk there it would not work.
- falcor84 6y agoYou're right regarding glob functionality, but the curly braces are a separate shell feature. The most useful idiom I use it for is renaming or copying, e.g.: cp filename{,_backup}
- lloeki 6y agoThe feature is called brace expansion: https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html#Brace-Expansion https://www.gnu.org/software/bash/manual/html_node/Brace-Exp... You may also be interested in yet another powerful feature that is parameter expansion: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html https://www.gnu.org/software/bash/manual/html_node/Shell-Par... Filename expansion (nitpick: often mistaken for globbing) is performed last: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html#Filename-Expansion https://www.gnu.org/software/bash/manual/html_node/Filename-...
- account42 6y ago> nitpick: often mistaken for globbing What exactly would you call globbing if not the feature that is controlled using the nullglob, failglob, nocaseglob and dotglob options as well as the GLOBIGNORE variable.
- lloeki 6y agoGlobbing has an ambivalent definition given that it’s mostly used for filename matches (especially given its origin as the glob command), but it’s really a specific form of pattern matching using wildcards such as * and ?, it need not apply only to filenames or paths on the filesystem: this matching is also used to match strings in case/in/esac constructs and test’s == != https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs https://www.gnu.org/software/bash/manual/bash.html#Condition... I guess one could say globbing is applying this pattern matching to filter a list.