我正在嘗試cp在 ubuntu 20 下運行良好的命令,即
(base) jr@Historys-MacBook-Air test % cp --backup=numbered src dest
cp: illegal option -- -
這讓我覺得很奇怪,所以檢查我看到的手冊頁
HISTORY
A cp command appeared in Version 1 AT&T UNIX.
macOS 12.0 February 23, 2005
我認為貝殼可能是罪魁禍首——我發現我在zsh
(base) jr@Historys-MacBook-Air test % echo $0
-zsh
當我在 bash 中啟動一個終端時,它是一個舊版本:
(base) jr@Historys-MacBook-Air test % /bin/bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.
所以我嘗試brew install了最新的然后 chsh 到它但得到了“非標準外殼”:
...
==> Pouring bash--5.1.16.arm64_monterey.bottle.tar.gz
?? /opt/homebrew/Cellar/bash/5.1.16: 157 files, 11.5MB
(base) jr@Historys-MacBook-Air test % /opt/homebrew/Cellar/bash/5.1.16/bin/bash --version
GNU bash, version 5.1.16(1)-release (aarch64-apple-darwin21.1.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(base) jr@Historys-MacBook-Air test % chsh -s /opt/homebrew/Cellar/bash/5.1.16/bin/bash
Changing shell for jr.
Password for jr:
chsh: /opt/homebrew/Cellar/bash/5.1.16/bin/bash: non-standard shell
任何人都可以指出如何。運行 5.1.16 bash 和/或 b。在 mac os12 上使用cp --backup=numbered(和/或 c。權衡 bash 版本是否是破壞我的 cp 命令的原因?)
uj5u.com熱心網友回復:
回答你的三個問題:
- 添加
/opt/homebrew/Cellar/bash/5.1.16/bin/bash(或更好,opt/local/bin/bash這是它的符號鏈接)到/etc/shells - macOS 附帶的
cp版本與 GNU 版本不同。它缺少--backup=numbered選項。您將需要安裝GNU CoreutilsfromHomebrew以獲得您想要的行為。GNU命令cp將以GNU開頭g。gcpcp bash和zsh版本都與命令cp的選項或行為沒有任何關系。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/447166.html
上一篇:Java多執行緒【三種實作方法】
