為什麼沒有通配符“?”工作?

為什麼沒有通配符“?”工作?

我正在學習透過 WSL 在 Ubuntu 上使用終端。現在我正在練習通配符,但是?通配符對我不起作用。

正如您所看到的,*通配符有效,但這個無效:

$ ls file*
file.html file.js file.txt
$ ls dot*
dot.txt dot1902.html dot2.txt
$ ls *.html
archivoPruebaClase.html dot1902.html file.html
$ ls dot?
ls: cannot access 'dot?': No such file or directory
$ ls index?
ls: cannot access 'index?': No such file or directory

答案1

我認為它工作得很好:

  • A*將被替換為命令列上任意數量的字元。

  • A?將被恰好替換為一個字元。

因此,例如ls dot?.txt將顯示dot1.txtdot2.txt等,但不會例如顯示dot10.txt

嘗試ls -a列出該資料夾中的所有檔案/資料夾,然後您可以計算出應使用通配符列出的內容。

相關內容