File Names and File Globbing Flashcards Preview

Networking > File Names and File Globbing > Flashcards

Flashcards in File Names and File Globbing Deck (18):
1

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.)

2

Although filenames can contain almost any character, that doesn't mean that they...?

should.

3

Files that start with _____ are "hidden" files.

.

4

The *, ?, [...], and [^...] characters can be used to match filenames, through a process commonly called...?

"file globbing"

5

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.

6

Linux filenames can be up to _____ characters long, excluding any directory components.

255

7

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.)

8

You should avoid using punctuation in filenames since ...?

the uninformed use of shell meta-characters can produce disastrous results.

9

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)

10

A file name with a leading or trailing space is ...?

legal, (but very tricky to identify in a file listing)

11

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.)

12

Hidden files also do not appear in...?

a "glob", unless the leading dot was specifically listed.

13

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.

14

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".

15

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

16

The bracket wildcards represent a list of...?

single characters. (Thus [aeiou] matches any one vowel. A contiguous range of characters may be represented using a dash, as in [a-z] for the lowercase alphabet. A leading carat (^) negates the list, so that [^aeiou] is any character except a vowel. A "real" dash or carat can be represented by escaping the characters using a backslash (\). Thus, the expression [a\-z] matches a, z or a dash only. Ranges and single characters can be mixed together. The pattern [A-Za-z0-9._\-+~] matches any one of the "safe" filename characters.)

17

Wildcard Examples...?

Pattern Generates the list
* all the files in the list

*.html page1.html page2.html

page*.htm* page1.html page2.html page3.htm page40.htm

image?.* image1.jpeg image2.jpeg

[ps]* page1.html page2.html page3.htm page40.htm script1.pl

[^ps]* image1.jpeg image2.jpeg image10.jpeg image11.jpeg

18

Many commands behave differently when there are ...?

no files listed as opposed to when one or more files are given as part of the command. (So what happens in such a command if a wildcard pattern is used, and the pattern does not match anything so that the list of files is empty? in the special case where the bash shell attempts to expand a wildcard expression and there is no match, it leaves the original expression as part of the command.)