日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux文件名通配符:* ? [:digit:]数字 [:lower:]小写字母 [:upper:]大写字母

發布時間:2025/5/22 linux 171 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux文件名通配符:* ? [:digit:]数字 [:lower:]小写字母 [:upper:]大写字母 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? ?通配符命令簡介:

? ? ? 匹配符合相關條件的符號,匹配文件名查找。


? 通配符類型:

? ? ? *:匹配任意長度的任意字符

? ? ? ??:匹配任意單個字符

? ? ? ?[]:匹配指定范圍內的任意單個字符

? ? ? ?[^]:匹配指定范圍之外的任意單個字符

? ? ? ?[:space:]:空白字符

? ? ? ?[:punct:]:標點符號

? ? ? ?[:lower:]:小寫字母

? ? ? ?[:upper:]:大寫字母

? ? ? ?[:alpha:]:大小寫字母

? ? ? ?[:digit:]:數字

? ? ? ?[:alnum:]:數字和大小寫字母

? ?

通配符命令實例練習:

? 1、創建a123,cd6,c78m,cl my,m.z,k 67,8yu,789等文件:注意,以上是以逗號為分隔符,

? 其余都是文件名組成部分。

?[root@xuelinux test1]# touch a123 cd6 c78m 'cl my' m.z 'k 67'?8yu?789

? [root@xuelinux test1]# ls -l

總用量 0

-rw-r--r--. 1 root root 0 10月 11 14:34 789

-rw-r--r--. 1 root root 0 10月 11 14:34 8yu

-rw-r--r--. 1 root root 0 10月 11 14:34 a123

-rw-r--r--. 1 root root 0 10月 11 14:34 c78m

-rw-r--r--. 1 root root 0 10月 11 14:34 cd6

-rw-r--r--. 1 root root 0 10月 11 14:34 cl my

-rw-r--r--. 1 root root 0 10月 11 14:34 k 67

-rw-r--r--. 1 root root 0 10月 11 14:34 m.z

? 2、顯示所有以a或者m開頭的文件:?

? ? ls -l [am]*

[root@xuelinux test1]# ls -l [am]*

-rw-r--r--. 1 root root 0 10月 11 14:34 a123

-rw-r--r--. 1 root root 0 10月 11 14:34 m.z

?3、顯示所有文件名中包含了數字的文件:

? ? ls -l *[0-9]* 或者ls -l *[[:digit:]]*

[root@xuelinux test1]# ls -l *[0-9]*

-rw-r--r--. 1 root root 0 10月 11 14:34 789

-rw-r--r--. 1 root root 0 10月 11 14:34 8yu

-rw-r--r--. 1 root root 0 10月 11 14:34 a123

-rw-r--r--. 1 root root 0 10月 11 14:34 c78m

-rw-r--r--. 1 root root 0 10月 11 14:34 cd6

-rw-r--r--. 1 root root 0 10月 11 14:34 k 67

? 4、顯示所有以數字結尾且文件名中不包含空白符的文件:

? ? ?ls -l *[^[:space:]]*[0-9] ?此命令無法精確排除,所以通配符不能完美的匹配此類情況。

[root@xuelinux test1]# ls -l *[^[:space:]]*[0-9]

-rw-r--r--. 1 root root 0 10月 11 14:34 789

-rw-r--r--. 1 root root 0 10月 11 14:34 a123

-rw-r--r--. 1 root root 0 10月 11 14:34 cd6

-rw-r--r--. 1 root root 0 10月 11 14:34 k 67 ? 此文件名按道理是不應該被匹配的

? 5、顯示文件名中包含了非字母或數字的特殊符號的文件:

? ? ls -l *[^[:alnum:]]*

[root@xuelinux test1]# ls -l *[^[:alnum:]]*

-rw-r--r--. 1 root root 0 10月 11 14:34 cl my

-rw-r--r--. 1 root root 0 10月 11 14:34 k 67

-rw-r--r--. 1 root root 0 10月 11 14:34 m.z


轉載于:https://blog.51cto.com/woyaoxuelinux/1860662

總結

以上是生活随笔為你收集整理的linux文件名通配符:* ? [:digit:]数字 [:lower:]小写字母 [:upper:]大写字母的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。