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,而且我已經做了更新。
天哪謝謝!這對我來說完全不直觀。你剛剛把我的信仰放回腳本先生:) –