File Names and File Globbing Flashcards
File names can contain almost any character except…?
/ (it can’t be part of a filename since it’s the character used to separate directory name components in a relative or fully-qualified name. Since many of the more “unusual” characters are shell metacharacters, they must be protected in quotes to be used in a filename.)
Although filenames can contain almost any character, that doesn’t mean that they…?
should.
Files that start with _____ are “hidden” files.
.
The *, ?, […], and [^…] characters can be used to match filenames, through a process commonly called…?
“file globbing”
Many OS’s restrict the choice and number of characters that can be used in naming files, in Linux….?
virtually any printable character can be used in a filename, and filenames can be of almost any length.
Linux filenames can be up to _____ characters long, excluding any directory components.
255
When used in a command, an absolute or relative filename, including directory components, may be up to …..?
4095 characters long. (This allows names of files and directories to be very descriptive.)
You should avoid using punctuation in filenames since …?
the uninformed use of shell meta-characters can produce disastrous results.
In general, filenames should be composed of …?
alphabetic and numeric characters (A-Z, a-z, 0-9) and the punctuation symbols ._-+~ (dot, underscore, dash, plus, tilde). Normally, filenames should start with an alphanumeric character or a dot. While you will encounter them with some frequency, files with embedded spaces are discouraged. (but putting quotes around a file with a space in the middle, will not cause any errors)
A file name with a leading or trailing space is …?
legal, (but very tricky to identify in a file listing)
File and directory names (remember directory is a type of file) that start with a dot are…?
“hidden” files. (Hidden files do not appear in the directory listings produced by ls unless the special command option -a (all) is used, or unless you specify the leading dot as part of the name. This makes it possible to reduce clutter and confusion by keeping certain files “out of sight, out of mind”. Except for hiding the file, the leading dot has no other significance, and hidden files and directories can be used just like any others.)
Hidden files also do not appear in…?
a “glob”, unless the leading dot was specifically listed.
Commands like cp -r and rm -r work on entire directory sub-trees, but Linux has a more…?
flexible way of identifying sets of files.
The bash command shell treats some of its special meta-characters as…?
wildcard characters. (When bash reads the command line, the shell performs a process called meta-character expansion or wildcard expansion, generates a list of filenames that match the pattern described by the wildcard expression, and then it passes the generated list on to the command. This is commonly referred to as “filename globbing”.
Wildcard characters….?
Character Effect
* matches zero or more characters (except leading dot)
? matches exactly one character (except leading dot)
[…] matches exactly one character from the list or range
[^…] matches exactly one character not from the list or range