日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

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

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

? ?通配符命令簡介:

? ? ? 匹配符合相關(guān)條件的符號,匹配文件名查找。


? 通配符類型:

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

? ? ? ??:匹配任意單個(gè)字符

? ? ? ?[]:匹配指定范圍內(nèi)的任意單個(gè)字符

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

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

? ? ? ?[:punct:]:標(biāo)點(diǎn)符號

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

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

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

? ? ? ?[:digit:]:數(shù)字

? ? ? ?[:alnum:]:數(shù)字和大小寫字母

? ?

通配符命令實(shí)例練習(xí):

? 1、創(chuàng)建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、顯示所有文件名中包含了數(shù)字的文件:

? ? 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、顯示所有以數(shù)字結(jié)尾且文件名中不包含空白符的文件:

? ? ?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 ? 此文件名按道理是不應(yīng)該被匹配的

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

? ? 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


轉(zhuǎn)載于:https://blog.51cto.com/woyaoxuelinux/1860662

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。