我有一個目錄,並在其中有幾個文件。我試圖解密這些文件並將它們移動到另一個目錄。我無法弄清楚如何設置輸出文件名並將其移動。Shell腳本解密和移動文件從一個目錄到另一個目錄
因此,目錄結構如下所示:
/Applications/MAMP/bin/decryptandmove.sh
/Applications/MAMP/bin/passtext.txt
/Applications/MAMP/bin/encrypted/test1.txt.pgp
/Applications/MAMP/bin/encrypted/test2.txt.pgp
/Applications/MAMP/htdocs/www/decrypted/
對於所有在加密的目錄中的文件,我試圖對其進行解密,然後將它們移動到目錄WWW /解密/。我不知道加密目錄中的文件名會提前(此腳本最終將通過cron作業運行),所以我只想輸出具有相同文件名的解密文件,但沒有pgp。因此,結果將是:
/Applications/MAMP/bin/decryptandmove.sh
/Applications/MAMP/bin/passtext.txt
/Applications/MAMP/bin/encrypted/
/Applications/MAMP/htdocs/decrypted/test1.txt.pgp
/Applications/MAMP/htdocs/decrypted/test2.txt.pgp
所以,這是我迄今爲止所寫的,它不起作用。 FILE和FILENAME都是錯誤的。我甚至沒有接觸到移動部分。
pass_phrase=`cat passtext.txt|awk '{print $1}'`
for FILE in '/Applications/MAMP/bin/encrypted/';
do
FILENAME=$(basename $FILE .pgp)
gpg --passphrase $pass_phrase --output $FILENAME --decrypt $FILE
done
我一直在嘗試使用這個,但我不斷收到: gpg:/ Applications/MAMP/bin/encrypted /:讀取錯誤:是目錄 gpg:decrypt_message失敗:eof – KittyYoung 2010-03-25 02:51:49
哦,等等...你改變它:)讓我再試一次... – KittyYoung 2010-03-25 02:52:30
它是完美的!非常感謝你。我完全不瞭解大部分的語法,但我一定會試着弄清楚它的含義。 – KittyYoung 2010-03-25 03:03:46