Open main menu

CDOT Wiki β

Changes

OPS102 - File Globbing, Common Commands, Text Editors

1,834 bytes added, 05:13, 18 September 2023
Created page with "== File Globbing / Ambiguous Filenames / Filename Patterns == Linux and Windows systems both allow ambiguous filenames, which use ''wildcard'' symbols to enable filename matc..."
== File Globbing / Ambiguous Filenames / Filename Patterns ==

Linux and Windows systems both allow ambiguous filenames, which use ''wildcard'' symbols to enable filename matching. The process of converting an ambiguous filename, or filename pattern, into a list of matchine filenames is called ''globbing'' or ''filename expansion''.

On a Linux system, globbing is performed by the shell. This means that all arguments are subject to globbing, whether they're intended to be a filename argument or not.

On a Windows system, ambiguous filenames are converted into a list of filenames by the command or application. This means that arguments that are not filenames are not subject to filename expansion. However, it also means that applications must contain additional code to perform globbing.

=== Wildcard Symbols ===

{|cellspacing="0" width="100%" cellpadding="5" border="1" style="background: #ffffff"
|-
!Symbol!!Meaning in Linux!!Meaning in Windows
|-
|*||Matches zero or more characters||Matches zero or more characters
|-
|?||Matches one character||Matches one character, unless at the end of the filename or immediately before the dot preceeding the extension or at the end of the name
|-
|<nowiki>[</nowiki>''list''<nowiki>]</nowiki>||Matches any one of the characters within the brackets||''Not applicable''
|}

=== Examples ===

{|cellspacing="0" width="100%" cellpadding="5" border="1" style="background: #ffffff"
|-
!Pattern!!Matches on Linux!!Does not match on Linux!!Matches on Windows!!Does not match on Windows
|-
|a*||a aa aaa alpha argonaut||Alpha banana||a aa aaa alpha Alpha||banana
|-
|b*e||blue bite||red green blot||blue bite||red green blot
|-
|c[oa]t||cat cot||coat|| ||cat cot coat ''(Not applicable)''
|-
|d?e||due doe||duo Doe date||due doe Doe||duo date
|-
|a??||aaa abc||aa abcd||aaa abc aa||abcd
|}