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.

archive
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"
  1. archive ← app.tar

    3archive="app.tar"4files=("index.html" "style.css" "app.js")
    values this stepapp.tararchive
  2. files ← 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.jsfiles
  3. file_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.jsfiles
  4. command ← 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_list
  5. echo "$command"

    6command="tar -cf $archive $file_list"7echo "$command"
    outputtar -cf app.tar index.html style.css app.js
    values this steptar -cf app.tar index.html style.css app.jscommand
  1. archive ← logs.tar

    3archive="logs.tar"4files=("index.html" "style.css" "app.js")
    values this steplogs.tararchive
  2. files ← 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.jsfiles
  3. file_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.jsfiles
  4. command ← 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_list
  5. echo "$command"

    6command="tar -cf $archive $file_list"7echo "$command"
    outputtar -cf logs.tar index.html style.css app.js
    values this steptar -cf logs.tar index.html style.css app.jscommand
  1. archive ← backup.tar

    3archive="backup.tar"4files=("index.html" "style.css" "app.js")
    values this stepbackup.tararchive
  2. files ← 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.jsfiles
  3. file_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.jsfiles
  4. command ← 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_list
  5. echo "$command"

    6command="tar -cf $archive $file_list"7echo "$command"
    outputtar -cf backup.tar index.html style.css app.js
    values 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.