
我正在嘗試使用 .bashrc 檔案中的別名來修改 ls 命令,但出現了一些奇怪的錯誤。
.bashrc 文件
export http_proxy="Some URL"
export https_proxy=$http_proxy
alias ls='ls --color'
然後,當我嘗試時ls
,輸出是
's: unrecognized option '--color
Try 'ls --help' for more information.
如果我從 .bashrc 中刪除別名並運行ls --color
,我會看到預期的結果。
我不確定我做錯了什麼,但我們將不勝感激。每次進行更改時,我都會重新啟動終端以確保重新加載 .bashrc。作業系統是Ubuntu 14.04。
一些可能相關的事情
: command not found
當我打開一個新的.bashrc 中的空白行時,它會顯示在終端上。- 如果我
alias ls='ls --color'
在終端中運行,別名可以正常工作。 - 從技術上講,我在 Windows 上使用 Cygwin 透過 SSH 連接到這個 Ubuntu VM。
相關問題
為什麼 .bashrc 檔案中定義的別名不起作用?
http://www.linuxquestions.org/questions/linux-newbie-8/bashrc-aliases-don't-工作-267885/
別名在 Debian 中不起作用
https://unix.stackexchange.com/questions/44616/why-is-vim-creating-files-with-dos-line-endings
答案1
發現問題了。我注意到當我在 vim 中打開 .bashrc 時,[dos]
底部有一些東西。
然後我把dos2unix .bashrc
它轉換為 Unix 檔案結尾,問題就解決了。
經過進一步閱讀,Cygwin 似乎可能與 dos 行結尾有關。看https://unix.stackexchange.com/questions/44616/why-is-vim-creating-files-with-dos-line-endings。