Shell
為什麼這個帶有萬用字元的 sudo mv 操作不起作用?
我認為必須有一個簡單的答案,但我無法弄清楚為什麼這不起作用!
我的主目錄中有一個名為installed-plugins 的文件夾(嗯,向下幾級)。我想將該文件夾的所有內容(大約 15 個 .jar 文件)傳輸到不同的文件夾,也稱為已安裝外掛。
這就是我正在嘗試的:
$ sudo mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/ mv: cannot stat `/home/jira-plugins/installed-plugins/*': No such file or directory
我的錯誤是什麼?
該文件夾絕對不是空的。這是
ls
輸出:$ sudo ls /home/jira-plugins/installed-plugins analytics-client-3.15.jar plugin.2223138796603023855.jira-importers-plugin-6.0.30.jar atlassian-chaperone-2.0.3.jar plugin.330169947367430109.jira-fisheye-plugin-6.2.8.jar atlassian-client-resource-1.0.jar plugin.4363048306537053933.jeditor-2.1.7.2.jar atlassian-pocketknife-api-commons-plugin-0.19.jar plugin.4438307615842123002.jira-ical-feed-1.0.4.jar atlassian-pretty-urls-plugin-1.8.jar plugin.461510159947098121.jira-issue-collector-plugin-1.2.5.jar base-hipchat-integration-plugin-7.8.24.jar plugin.5630909028354276764.atlassian-universal-plugin-manager-plugin-2.7.8.jar base-hipchat-integration-plugin-api-7.8.24.jar plugin.6920509095052318016.atlassian-bonfire-plugin-2.9.13.jar hipchat-core-plugin-0.8.3.jar plugin.6952408596192442765.atlassian-bonfire-plugin-2.8.2.jar hipchat-for-jira-plugin-1.2.11.jar plugin.7079751365359230322.jira-importers-bitbucket-plugin-1.0.8.jar jira-email-processor-plugin-1.0.29.jar plugin.7451827330686083284.atlassian-universal-plugin-manager-plugin-2.21.4.jar jira-fisheye-plugin-7.1.1.jar plugin.7498175247667964103.jira-importers-redmine-plugin-2.0.7.jar jira-ical-feed-1.1.jar plugin.7803627457720701011.jira-importers-plugin-3.5.3.jar jira-issue-nav-components-6.2.23.jar plugin.7977988994984147602.jira-bamboo-plugin-5.1.6.jar jira-servicedesk-2.3.6.jar plugin.8372419067824134899.jira-importers-plugin-5.0.2.jar jira-workinghours-plugin-1.5.5.jar plugin.9081077311844509190.jira-fisheye-plugin-5.0.13.jar plugin.1260160651631713368.stp-3.0.11.jar plugin.9128973321151732551.jira-fisheye-plugin-6.3.10.jar plugin.2076016305412409108.jira-fisheye-plugin-3.4.10.jar plugin-license-storage-plugin-2.8.jar plugin.218965759549051904.jira-importers-plugin-6.1.5.jar querydsl-4.0.7-provider-plugin-1.1.jar plugin.2211202876682184330.jira-ical-feed-1.0.12.jar stp-3.5.10.jar
這幾乎可以肯定是因為您的普通使用者帳戶無法訪問該目錄,因此 shell 無法列舉與萬用字元匹配的文件。
您可以使用這樣的命令輕鬆地確認這一點
ls /home/jira-plugins/installed-plugins
如果您獲得一個權限被拒絕,那麼 shell 將無法
*
在該目錄中擴展萬用字元。為什麼?考慮你的命令
sudo mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/
處理順序是 (1) 擴展萬用字元,(2) 執行命令,在這種情況下,它
sudo
帶有一些恰好對應於mv
語句的參數。您可以通過以下兩種方式之一解決問題
- 成為root,然後移動文件
sudo -s mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/
- 執行後展開萬用字元
sudo
sudo bash -c "mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/"