What is the meaning of asterisk, backslash, colon and two in (*\:2)?

*\:2,*T is the glob pattern of files to list. To understand it, we need to remember a few things:

  • : has to be escaped in the shell, becoming \:
  • File names can easily contain commas

So *\:2,*T would e.g. match a file called TranscationNumber:2,EventType:XYT

EDIT

From the comments, the necessity (or not) of escaping the : needs a few words: It is not strictly necessary to escape the : sign, but bash itself suggests it when autocompleting.


List all files that match the wildcard pattern *:2,*T

There the wildcard * matches anything (any number of all possible characters)
:2, are characters that need to be present in the file/directory names.
The colon : is a special character that needs to be escaped, hence the form of \:2,.
The file/directory names need to end with a T.

File names that would match would be

:2,T
a:2,T
a:2,bT
abbY-$fafaf:2,<hskjhsgdfhjk>T

As others have noted, this will list in long format, files containing :2, and ending in T

This looks like a search in a Maildir folder for files that were deleted (trashed). However, for robustness it should have had another * at the end, though. New flags with a later alphabetical position could be added, and Dovecot for instance adds another field with the file size at the end.

  • https://cr.yp.to/proto/maildir.html

Tags:

Bash

Expansion