Terminal

mv 引發錯誤消息,但文件已移動

  • April 14, 2018

我承認我不是 unix 命令方面的專家,但我將文件移動到另一個目錄並收到一條錯誤消息 - 但文件已被移動。為什麼會出現此消息“ mv: rename to to /Users/billtubbs/Library/Script Libraries/to: No such file or directory”?是因為圖書館是一個受保護的文件夾,我應該使用sudo ...

這是在 Mac OS X 10.13.4 的終端中:

BillsMacBookPro:Scripts billtubbs$ ls ~/Library/'Script Libraries'
BillsMacBookPro:Scripts billtubbs$ mv FileHandlers.scpt to ~/Library/'Script Libraries'
mv: rename to to /Users/billtubbs/Library/Script Libraries/to: No such file or directory
BillsMacBookPro:Scripts billtubbs$ ls
Address Book Scripts                    Terminal scripts
Applications                            Test Script read html page .scpt
Bus Data                                Test script parse html form.scpt
Firefox scripts                         TextDataFromFile.scpt
ListHandlers.scpt                       TextHandlers.scpt
Mail Scripts                            What Time Is It? Old.scpt
Morning routine OLD.scpt                What Time Is It?.app
Morning routine.app                     What time is it?.scpt
Morning routine.scpt                    What time is it?.scptd
NumberHandlers.scpt                     When's the next bus?.scpt
Numbers scripts                         When's the next number 19 bus?.scpt
POF member details.scpt                 When's the next number 20 bus?.scpt
README.md                               When's the next number 25 bus?.scpt
Safari scripts                          mail subject line.scpt
Save mail message to file.scpt          mail_read.scpt
Speak_time.applescript                  save mail_copy.scpt
Speak_time.scpt                         search POF script.scpt
Speak_time.zip
BillsMacBookPro:Scripts billtubbs$ mv TextHandlers.scpt to ~/Library/'Script Libraries'
mv: rename to to /Users/billtubbs/Library/Script Libraries/to: No such file or directory
BillsMacBookPro:Scripts billtubbs$ ls ~/Library/'Script Libraries'
FileHandlers.scpt       TextHandlers.scpt
BillsMacBookPro:Scripts billtubbs$ ls TextH*
ls: TextH*: No such file or directory

因為你說

mv *(源文件名)*  **到**  *(目標目錄)*

並且 Unix 命令不是英語——你不會在某處  說類似的mv東西。鋸**to**mv

mv *(源文件名1 ) (源文件名2 )*   *(目標目錄)*

在哪裡,並且錯誤消息說沒有這樣的文件。(source filename2)to**to**

您似乎誤解了該mv命令的工作原理。參數中沒有to,因此它被解釋為文件名,但不存在這樣的文件。

man 1 mv

SYNOPSIS
  mv [OPTION]... [-T] SOURCE DEST
  mv [OPTION]... SOURCE... DIRECTORY
  mv [OPTION]... -t DIRECTORY SOURCE...

引用自:https://unix.stackexchange.com/questions/437822