Archives and Compression
Extract Target
Add a Destination
Extraction commands often need both an archive name and a destination directory. Keeping those values separate makes scripts easier to review.
Program
Play the script to choose the destination directory used in the extract command.
extract_target.sh
#!/usr/bin/env bash
target_dir=
archive="site.tar.gz"
mode="extract"
command="tar -xzf $archive -C $target_dir"
echo "$mode:$command"
#!/usr/bin/env bash
target_dir=
archive="site.tar.gz"
mode="extract"
command="tar -xzf $archive -C $target_dir"
echo "$mode:$command"
#!/usr/bin/env bash
target_dir=
archive="site.tar.gz"
mode="extract"
command="tar -xzf $archive -C $target_dir"
echo "$mode:$command"
extract
`tar -xzf` is the common gzip-compressed tar extraction shape.
destination
`-C target` tells tar where to extract files.
separate values
Storing archive and target separately makes the final command easier to inspect.