0

Bash 新手 - 我正在尝试运行一个脚本,该脚本使用同上从已安装的 Windows 驱动器复制配置文件。我已经使用包含的用户名运行了同上命令,所以知道它可以工作,现在尝试使用变量输入来运行。但是得到一个错误消息。我已经尝试在变量周围使用“”,但仍然出现错误 - 我错过了什么?

#!/bin/bash

echo "Enter user name: " 
read username

echo "Transfer of $username profile started at " > ~/Desktop/transfer.log
date >> ~/Desktop/transfer.log
clear
echo "Transferring Data Folder to Documents Folder"
ditto -v /Volumes/C/Data ~/Documents/Data 2>> ~Desktop/transfer.log
echo "Data transfer complete"

echo "Transferring Documents Folder - Will error on system folders My Music, My Pictures, My Videos"
ditto -v /Volumes/C/Users/$username/Documents ~/Documents 2>> ~Desktop/transfer.log
echo "Documents transfer complete"

echo "Transferring Downloads Folder"
ditto -v /Volumes/C/Users/$username/Downloads ~/Documents/Downloads 2>> ~Desktop/transfer.log
echo "Downloads transfer complete"

echo "Transferring Favorites Folder to Documents Folder"
ditto -v /Volumes/mpc/Users/$username/Favorites ~/Documents/Favorites 2>> ~Desktop/transfer.log
echo "Favorites transfer complete"

echo "Transferring Desktop Folder"
ditto -v /Volumes/C/Users/$username/Desktop ~/Desktop 2>> ~Desktop/transfer.log
echo "Desktop transfer complete"

echo "Transferring Music Folder"
ditto -v /Volumes/C/Users/$username/Music ~/Music 2>> ~Desktop/transfer.log
echo "Music transfer complete"

echo "Transferring Pictures Folder"
ditto -v /Volumes/C/Users/$username/Pictures ~/Documents/Pictures 2>> ~Desktop/transfer.log
echo "Pictures transfer complete"

echo "Transferring Videos Folder"
ditto -v /Volumes/C/Users/$username/Videos ~/Videos 2>> ~Desktop/transfer.log
echo "Videos transfer complete"

echo "Transferring PST from AppData to Documents Folder"
cp -v /Volumes/C/Users/$username/AppData/Local/Microsoft/Outlook/*.pst ~/Documents/Outlook Files 2>> ~Desktop/transfer.log
echo "AppData transfer complete"

echo "Removing My Music, My Pictures, My Videos"
rm -r "~/Documents/My Music"
rm -r "~/Documents/My Pictures"
rm -r "~/Documents/My Videos"
echo "Removal complete"

echo "Transfer Complete - Press any key to exit"
read Exit
exit
4

0 回答 0