使用 tar 创建包含所有源和数据的存档

问题描述 投票:0回答:0

我正在尝试使用

tar
命令创建包含所有应用程序源和数据的存档,但仍然给我一个错误。

# Prepare simple example files/dirs
mkdir /c/Projects/sandbox
cd /c/Projects/sandbox/
mkdir sub_sandbox

# create two txt files and put there some text
touch file1.txt file2.txt
echo hello >> file1.txt
echo world >> file2.txt

BUNDLE_PATH="./bundle.tar.gz"
CONTENT_DIRECTORY="/sandbox/sub_sandbox"

# Remove any bundle from previous attempts.
rm -f "${BUNDLE_PATH}"
# Create an archive with all of our application source and data.
echo "Creating bundle archive: ${BUNDLE_PATH}"
#tar czf "${BUNDLE_PATH}" file1.txt file2.txt
tar czf "${BUNDLE_PATH}" -C "${CONTENT_DIRECTORY}" .

我得到的错误:

tar: /sandbox/sub_sandbox: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

你能给我一个提示我忽略了什么吗?非常感谢您对此提供的任何帮助。

linux bash sh tar
© www.soinside.com 2019 - 2024. All rights reserved.