Here is the list tar builds the archive from, and where .release got lost on the way.
tar packs files and directories into one archive file. The -c option creates an archive, -f sets its file name. Every stored file or directory is an archive member: a path, contents, mode, owner and modification time.
The nightly script builds the archive like this:
app/* is a filename pattern: Bash replaces it with the list of matching names before tar even starts, as in the "Help and the shell" lesson. Names that start with a dot are not matched by *. tar received app/bin, app/config, app/data and app/secret.env, and never heard of .release.
Give tar a whole directory and it walks it itself, hidden files included:
-C changes into a directory before tar reads the names that follow. That is why the paths inside the archive start with app/. Whatever paths the archive records are the paths that appear on extraction:
| Command | Paths in the archive |
|---|---|
tar -cf a.tar app/* |
app/bin/…, app/secret.env; no .release |
tar -cf a.tar -C live app |
app/, app/.release, app/bin/… |
tar -cf a.tar live/app |
live/app/… — an extra level |
You are in student's home directory. You need to save all of it, .bashrc included. Which command does it?
-
tar stores everything it receives, but the
*pattern hands it a list without the hidden names. -
The same
*pattern: Bash substitutes the names without a leading dot, and.bashrcstays out of the archive. -
Bash expands the
*pattern, and names starting with a dot stay out of the list. Check:echo /home/student/*does not show.bashrc.
Given a whole directory, tar walks it itself and stores every name, .bashrc included. Bash expands the * pattern before tar starts, and hidden names stay out of the list.
Key points
- tar stores only the names it receives; given a whole directory, it walks it with every file, hidden ones included.
-
Bash expands the
*pattern before tar starts, and names beginning with a dot stay out of the list. -
The command decides the paths inside the archive: with
-C live appthey start withapp/.