1
这是一个非常简短的问题。但是将变量$example
作为tar的参数放在bash文件中是否存在某些合成错误?
我有一个文件写成
//only portion that really matters
#!/bin/bash
...
tar -cvpzf $filename $backup_source
//here's the actual code
#!/bin/bash
backup_source="~/momobobo"
backup_dest="~/momobobo_backup/"
dater=`date '+%m-%d-%Y-%H-%M-%S'`
filename="$backup_dest$dater.tgz"
echo “Backing Up your Linux System”
tar -cvpzf $filename $backup_source
echo tar -cvpzf $filename $backup_source
echo “Backup finished”
//and heres the error
“Backing Up your Linux System”
tar: ~/momobobo: Cannot stat: No such file or directory
tar (child): ~/momobobo_backup/07-02-2013-18-34-12.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar -cvpzf ~/momobobo_backup/07-02-2013-18-34-12.tgz ~/momobobo
公告的 “回声焦油......”。当我复制并粘贴输出并在终端中运行时,文件不会出现问题。我目前正在运行Xubuntu,而且我已经做了更新。
天哪谢谢!这对我来说完全不直观。你刚刚把我的信仰放回脚本先生:) –