我有以下情況:
$ ls
0.txt aaa.txt a-.txt a.txt b.txt ddd.txt -hello.txt libs -.txt ,.txt !.txt ].txt \.txt
$ ls [-a]*.txt
ls: opzione non valida -- "e"
Try 'ls --help' for more information.
$ ls [a-]*.txt
ls: opzione non valida -- "e"
Try 'ls --help' for more information.
破折號 ( -
) 會產生一些問題。如何找到以 開頭的檔案-
?
答案1
用於--
指示 的選項結束ls
:
ls -- -*
或執行以下操作以明確指示目前目錄上的參數./
ls ./-*
如果您想為 輸入更多選項ls
,請將它們放在--
或之前,./
例如
ls -l -- -*
ls -l ./-*