目錄內容
rtetteh@PW02R9F3:~/Projects$ ls -al
total 68
drwxr-xr-x 5 rtetteh rtetteh 4096 Oct 27 13:45 .
drwxr-xr-x 18 rtetteh rtetteh 4096 Oct 27 13:45 ..
-rw-r--r-- 1 rtetteh rtetteh 12288 Sep 30 15:19 .ThreadTest.cpp.swp
drwxr-xr-x 2 rtetteh rtetteh 4096 Oct 27 13:45 .recycleBin
-rw-r--r-- 1 rtetteh rtetteh 953 Oct 27 13:44 ThreadTest.cpp
-rwxr-xr-x 1 rtetteh rtetteh 24984 Sep 30 15:14 ThreadTest_exe
drwxr-xr-x 2 rtetteh rtetteh 4096 Aug 17 18:26 hello
drwxr-xr-x 6 rtetteh rtetteh 4096 Oct 21 15:12 python-account-manager
-rwxr-xr-x 1 rtetteh rtetteh 168 Aug 19 20:23 test_pos_param.sh
測驗 1
rtetteh@PW02R9F3:~/Projects$ ls -al *.sh
-rwxr-xr-x 1 rtetteh rtetteh 168 Aug 19 20:23 test_pos_param.sh
測驗 2
rtetteh@PW02R9F3:~/Projects$ ls -al *.swp
ls: cannot access '*.swp': No such file or directory
為什么測驗 1 作業而不是測驗 2。如何讓測驗 2 作業,即顯示擴展名為 .swp 的檔案
uj5u.com熱心網友回復:
您的錯誤假設是星號擴展為在字串的開頭包含“ . ”。Shell 默認值不會在正則運算式中匹配。
您需要專門指定“ .*.swp ”才能進行正確的擴展。這也不需要 ls 的 -a 開關,因為您指定了“ . ”前綴。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/522993.html
標籤:重击壳
