Archives and Compression
Tar Create
Build an Archive Command
Archive commands collect multiple paths into one file. A script can assemble the command from fixed inputs before running it.
Program
Play the script to choose the archive name and build the command text deterministically.
tar_create_plan.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash
archive="app.tar"
files=("index.html" "style.css" "app.js")
file_list="${files[*]}"
command="tar -cf $archive $file_list"
echo "$command"
#!/usr/bin/env bash
archive="logs.tar"
files=("index.html" "style.css" "app.js")
file_list="${files[*]}"
command="tar -cf $archive $file_list"
echo "$command"
#!/usr/bin/env bash
archive="backup.tar"
files=("index.html" "style.css" "app.js")
file_list="${files[*]}"
command="tar -cf $archive $file_list"
echo "$command"
archive ← app.tar
3archive="app.tar"4files=("index.html" "style.css" "app.js")values this stepapp.tararchivefiles ← index.html style.css app.js
3archive="app.tar"4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"values this stepindex.html style.css app.jsfilesfile_list ← index.html style.css app.js
4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"6command="tar -cf $archive $file_list"values this stepindex.html style.css app.jsfile_listindex.html style.css app.jsfilescommand ← tar -cf app.tar index.html style.css app.js
5file_list="${files[*]}"6command="tar -cf $archive $file_list"7echo "$command"values this steptar -cf app.tar index.html style.css app.jscommandapp.tararchiveindex.html style.css app.jsfile_listecho "$command"
6command="tar -cf $archive $file_list"7echo "$command"outputtar -cf app.tar index.html style.css app.jsvalues this steptar -cf app.tar index.html style.css app.jscommand
archive ← logs.tar
3archive="logs.tar"4files=("index.html" "style.css" "app.js")values this steplogs.tararchivefiles ← index.html style.css app.js
3archive="logs.tar"4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"values this stepindex.html style.css app.jsfilesfile_list ← index.html style.css app.js
4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"6command="tar -cf $archive $file_list"values this stepindex.html style.css app.jsfile_listindex.html style.css app.jsfilescommand ← tar -cf logs.tar index.html style.css app.js
5file_list="${files[*]}"6command="tar -cf $archive $file_list"7echo "$command"values this steptar -cf logs.tar index.html style.css app.jscommandlogs.tararchiveindex.html style.css app.jsfile_listecho "$command"
6command="tar -cf $archive $file_list"7echo "$command"outputtar -cf logs.tar index.html style.css app.jsvalues this steptar -cf logs.tar index.html style.css app.jscommand
archive ← backup.tar
3archive="backup.tar"4files=("index.html" "style.css" "app.js")values this stepbackup.tararchivefiles ← index.html style.css app.js
3archive="backup.tar"4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"values this stepindex.html style.css app.jsfilesfile_list ← index.html style.css app.js
4files=("index.html" "style.css" "app.js")5file_list="${files[*]}"6command="tar -cf $archive $file_list"values this stepindex.html style.css app.jsfile_listindex.html style.css app.jsfilescommand ← tar -cf backup.tar index.html style.css app.js
5file_list="${files[*]}"6command="tar -cf $archive $file_list"7echo "$command"values this steptar -cf backup.tar index.html style.css app.jscommandbackup.tararchiveindex.html style.css app.jsfile_listecho "$command"
6command="tar -cf $archive $file_list"7echo "$command"outputtar -cf backup.tar index.html style.css app.jsvalues this steptar -cf backup.tar index.html style.css app.jscommand
archive
A tar archive groups paths into one file.
array expansion
`"${files[*]}"` joins array elements with spaces for display.
command plan
This example builds command text without touching the filesystem.