• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
白_胖_子
Linux学习的生活就是这么朴实无华且枯燥
博客园    首页    新随笔    联系   管理    订阅  订阅

Linux预定义通配符及实例

通配符

Linux系统中预定义的字符 man 7 glob

[:alnum:]:任意一个数字或者字母  
[:alpha:]:任意一个大写或者小写的字母  
[:blank:]:水平空白字符  
[:cntrl:]:控制(非打印)字符
[:digit:]:任意一个数字,相当于0-9  
[:graph:]:图形字符  
[:lower:]:任意一个小写字母,相当于a-z 
[:print:]:可打印字符(能看得见的,不是换行符之类的)    
[:punct:]:标点符号
[:space:]:水平或垂直空白字符 
[:upper:]:任意一个大写字母,相当于A-Z  
[:xdigit:]:十六进制字符

范例:

  1. 显示/etc/test/目录下以l开头任意小写字母结尾,且中间至少出现一个数字的所有文件和目录列表
[21:25:31 root@C8-3-55 ~]#ls /etc/test/l*[:digit:]*[[:lower:]]

2.显示/etc目录下以任意一位数字开头,且以非数字结尾的文件和目录列表

[21:34:42 root@C8-3-55 ~]#ls /etc/test/[[:digit:]]*[^[:digit:]]

3.显示/etc目录下以非字母开头且后面跟了一个字母及其他任意长度任意字符的文件和目录列表

[21:35:28 root@C8-3-55 ~]#ls /etc/[^[:alpha:]][[:alpha:]]*

4.显示/etc目录下所有以rc开头,并且后面是0-6之间的数字,其他为任意字符的文件或目录列表


[21:43:48 root@C8-3-55 ~]#ls /etc/rc[0-6]*

5.显示/etc目录下以m,n,r,p开头且以.conf结尾的文件和目录列表

[21:45:00 root@C8-3-55 ~]#ls /etc/[mnrp]*.conf
/etc/man_db.conf  /etc/nsswitch.conf  /etc/resolv.conf
/etc/mke2fs.conf  /etc/php-fpm.conf   /etc/rsyslog.conf

6.只显示/root下的隐藏文件和目录列表


[21:49:05 root@C8-3-55 ~]#ls -a /root/.[^.]*
/root/.bash_history  /root/.gitconfig      /root/.tcshrc
/root/.bash_logout   /root/.lesshst        /root/.viminfo
/root/.bash_profile  /root/.mysql_history  /root/.wget-hsts
/root/.bashrc        /root/.nmcli-history  /root/.Xauthority
/root/.cshrc         /root/.online.sh.swp

/root/.config:
.  ..  procps

/root/.mozilla:
.  ..  extensions

/root/.ssh:
.  ..  id_rsa  id_rsa.pub  known_hosts
  1. 只显示/etc目录下的非隐藏文件和目录列表
[21:49:49 root@C8-3-55 ~]#ls /etc/[^.]*
/etc/adjtime                   /etc/man_db.conf
/etc/aliases                   /etc/mime.types
/etc/anacrontab                /etc/mke2fs.conf
/etc/asound.conf               /etc/motd
/etc/at.deny                   /etc/mtab
/etc/bashrc                    /etc/my.cnf
/etc/bindresvport.blacklist    /etc/nanorc
/etc/centos-release            /etc/netconfig
/etc/centos-release-upstream   /etc/networks
/etc/chrony.conf               /etc/nsswitch.conf
/etc/chrony.keys               /etc/nsswitch.conf.bak
/etc/cron.deny                 /etc/nsswitch.conf.rpmnew
/etc/crontab                   /etc/oddjobd.conf
/etc/crypttab                  /etc/os-release
/etc/csh.cshrc                 /etc/passwd
/etc/csh.login                 /etc/passwd-
/etc/DIR_COLORS                /etc/php-fpm.conf
/etc/DIR_COLORS.256color       /etc/php.ini
/etc/DIR_COLORS.lightbgcolor   /etc/pinforc
/etc/dracut.conf               /etc/printcap
/etc/environment               /etc/profile
/etc/ethertypes                /etc/protocols
/etc/exports                   /etc/rc.local
/etc/favicon.png               /etc/redhat-release
/etc/filesystems               /etc/resolv.conf
/etc/fprintd.conf              /etc/rpc
/etc/fstab                     /etc/rsyslog.conf
/etc/fuse.conf                 /etc/screenrc
/etc/GREP_COLORS               /etc/services
/etc/group                     /etc/sestatus.conf
/etc/group-                    /etc/shadow
/etc/grub2.cfg                 /etc/shadow-
/etc/gshadow                   /etc/shells
/etc/gshadow-                  /etc/sos.conf
/etc/host.conf                 /etc/subgid
/etc/hostname                  /etc/subgid-
/etc/hosts                     /etc/subuid
/etc/idmapd.conf               /etc/subuid-
/etc/inittab                   /etc/sudo.conf
/etc/inputrc                   /etc/sudoers
/etc/issue                     /etc/sudo-ldap.conf
/etc/issue.net                 /etc/sysctl.conf
/etc/kdump.conf                /etc/system-release
/etc/krb5.conf                 /etc/system-release-cpe
/etc/ld.so.cache               /etc/tcsd.conf
/etc/ld.so.conf                /etc/trusted-key.key
/etc/libaudit.conf             /etc/updatedb.conf
/etc/libuser.conf              /etc/usb_modeswitch.conf
/etc/locale.conf               /etc/vconsole.conf
/etc/localtime                 /etc/vimrc
/etc/login.defs                /etc/virc
/etc/logrotate.conf            /etc/wgetrc
/etc/machine-id                /etc/xattr.conf
/etc/magic                     /etc/xinetd.conf
/etc/mailcap                   /etc/yum.conf
/etc/makedumpfile.conf.sample

/etc/alternatives:
cifs-idmap-plugin  ifup  libnssckbi.so.x86_64    ncman  python
ifdown             ld    libwbclient.so.0.14-64  nmap   unversioned-python-man

/etc/audit:
auditd.conf  audit.rules  audit-stop.rules  plugins.d  rules.d

/etc/authselect:
authselect.conf  dconf-locks       password-auth   system-auth
custom           fingerprint-auth  postlogin       user-nsswitch.conf
dconf-db         nsswitch.conf     smartcard-auth

/etc/bash_completion.d:
authselect-completion.sh  bpftool  iprconfig  redefine_filedir  vdo  vdostats

/etc/binfmt.d:

/etc/chkconfig.d:

/etc/cifs-utils:
idmap-plugin

/etc/cni:
net.d

/etc/cockpit:
machines.d  ws-certs.d

/etc/containers:
certs.d  oci  policy.json  registries.conf  registries.d  storage.conf

/etc/cron.d:
0hourly  raid-check

/etc/cron.daily:
logrotate

/etc/cron.hourly:
0anacron

/etc/cron.monthly:

/etc/cron.weekly:

/etc/crypto-policies:
back-ends  config  local.d  state

/etc/dbus-1:
session.conf  session.d  system.conf  system.d

/etc/dconf:
db  profile

/etc/default:
grub  useradd

/etc/depmod.d:
dist.conf  kvdo.conf

/etc/dhcp:
dhclient.conf  dhclient.d

/etc/dnf:
aliases.d  dnf.conf  modules.d  modules.defaults.d  plugins  protected.d  vars

/etc/dracut.conf.d:

/etc/firefox:
pref

/etc/firewalld:
firewalld.conf  icmptypes  lockdown-whitelist.xml  zones
helpers         ipsets     services

/etc/fonts:
conf.d  fonts.conf

/etc/gcrypt:
random.conf

/etc/gnupg:

/etc/groff:
site-font  site-tmac

/etc/grub.d:
00_header          01_users      20_ppc_terminfo   40_custom
00_tuned           10_linux      30_os-prober      41_custom
01_menu_auto_hide  20_linux_xen  30_uefi-firmware  README

/etc/gss:
mech.d

/etc/httpd:
conf  conf.d  conf.modules.d  logs  modules  run  state

/etc/init.d:
functions  README

/etc/iproute2:
bpf_pinning  group      rt_dsfield  rt_realms  rt_tables
ematch_map   nl_protos  rt_protos   rt_scopes

/etc/iscsi:
initiatorname.iscsi  iscsid.conf

/etc/issue.d:
cockpit.issue

/etc/kernel:
install.d  postinst.d

/etc/krb5.conf.d:
crypto-policies  kcm_default_ccache

/etc/ld.so.conf.d:
bind-export-x86_64.conf  kernel-4.18.0-147.el8.x86_64.conf

/etc/libblockdev:
conf.d

/etc/libnl:
classid  pktloc

/etc/libreport:
events  events.d  plugins  workflows.d

/etc/libssh:
libssh_client.config  libssh_server.config

/etc/logrotate.d:
bootlog  chrony  httpd        mariadb  psacct  sssd    up2date
btmp     dnf     iscsiuiolog  php-fpm  samba   syslog  wtmp

/etc/lsm:
lsmd.conf  pluginconf.d

/etc/lvm:
archive  backup  cache  lvm.conf  lvmlocal.conf  profile

/etc/mcelog:
mcelog.conf  triggers

/etc/microcode_ctl:
ucode_with_caveats

/etc/modprobe.d:
firewalld-sysctls.conf  tuned.conf

/etc/modules-load.d:

/etc/motd.d:
cockpit

/etc/multipath:

/etc/my.cnf.d:
auth_gssapi.cnf  enable_encryption.preset  mysql-clients.cnf
client.cnf       mariadb-server.cnf

/etc/NetworkManager:
conf.d        dnsmasq.d         NetworkManager.conf
dispatcher.d  dnsmasq-shared.d  system-connections

/etc/nftables:
all-in-one.nft     ipv4-filter.nft  ipv6-filter.nft  netdev-ingress.nft
arp-filter.nft     ipv4-mangle.nft  ipv6-mangle.nft
bridge-filter.nft  ipv4-nat.nft     ipv6-nat.nft
inet-filter.nft    ipv4-raw.nft     ipv6-raw.nft

/etc/nginx:
conf.d  default.d

/etc/oddjob:

/etc/oddjobd.conf.d:
oddjobd-introspection.conf  oddjobd-mkhomedir.conf

/etc/openldap:
certs  ldap.conf

/etc/opt:

/etc/ostree:
remotes.d

/etc/PackageKit:
PackageKit.conf  Vendor.conf

/etc/pam.d:
atd          fingerprint-auth  postlogin       sshd              system-auth
chfn         login             remote          sssd-shadowutils  systemd-user
chsh         other             runuser         su                vlock
cockpit      passwd            runuser-l       sudo              vmtoolsd
config-util  password-auth     screen          sudo-i
crond        polkit-1          smartcard-auth  su-l

/etc/php.d:
20-bz2.ini       20-curl.ini      20-ftp.ini      20-phar.ini
20-calendar.ini  20-exif.ini      20-gettext.ini  20-sockets.ini
20-ctype.ini     20-fileinfo.ini  20-iconv.ini    20-tokenizer.ini

/etc/php-fpm.d:
www.conf

/etc/pipewire:
pipewire.conf

/etc/pkcs11:
modules

/etc/pki:
ca-trust  java  nssdb  rpm-gpg  rsyslog  tls

/etc/plymouth:
plymouthd.conf

/etc/pm:
config.d  power.d  sleep.d

/etc/polkit-1:
localauthority  localauthority.conf.d  rules.d

/etc/popt.d:

/etc/prelink.conf.d:
grub2.conf

/etc/profile.d:
bash_completion.sh  colorxzgrep.csh  env.sh    less.csh  which2.csh
colorgrep.csh       colorxzgrep.sh   gawk.csh  less.sh   which2.sh
colorgrep.sh        colorzgrep.csh   gawk.sh   sh.local
colorls.csh         colorzgrep.sh    lang.csh  vim.csh
colorls.sh          csh.local        lang.sh   vim.sh

/etc/rc0.d:

/etc/rc1.d:

/etc/rc2.d:

/etc/rc3.d:

/etc/rc4.d:

/etc/rc5.d:

/etc/rc6.d:

/etc/rc.d:
init.d  rc0.d  rc1.d  rc2.d  rc3.d  rc4.d  rc5.d  rc6.d  rc.local

/etc/rhsm:
syspurpose

/etc/rpm:
macros.dist

/etc/rsyslog.d:

/etc/rwtab.d:
logrotate  sssd

/etc/samba:
lmhosts  smb.conf  smb.conf.example

/etc/sasl2:

/etc/security:
access.conf       console.perms.d  namespace.d     pwquality.conf.d
chroot.conf       group.conf       namespace.init  sepermit.conf
console.apps      limits.conf      opasswd         time.conf
console.handlers  limits.d         pam_env.conf
console.perms     namespace.conf   pwquality.conf

/etc/selinux:
config  semanage.conf  targeted

/etc/setroubleshoot:
setroubleshoot.conf

/etc/skel:

/etc/smartmontools:
smartd.conf  smartd_warning.d  smartd_warning.sh

/etc/ssh:
moduli        ssh_host_ecdsa_key        ssh_host_rsa_key
ssh_config    ssh_host_ecdsa_key.pub    ssh_host_rsa_key.pub
ssh_config.d  ssh_host_ed25519_key
sshd_config   ssh_host_ed25519_key.pub

/etc/ssl:
certs

/etc/sssd:
conf.d  pki

/etc/sudoers.d:

/etc/sysconfig:
anaconda  ebtables-config   irqbalance  network-scripts  samba
atd       firewalld         kdump       nftables.conf    selinux
chronyd   grub              kernel      raid-check       smartmontools
console   htcacheclean      man-db      rhn              sshd
cpupower  ip6tables-config  modules     rsyslog
crond     iptables-config   network     run-parts

/etc/sysctl.d:
99-sysctl.conf

/etc/systemd:
coredump.conf  logind.conf    system       user
journald.conf  resolved.conf  system.conf  user.conf

/etc/terminfo:

/etc/test:
1a.log     la1d.log   la3d.log   lb2d.log   lc1d.log   lc3d.log   rc4B.log
1b.log     la1e5.log  la3e5.log  lb2e5.log  lc1e5.log  lc3e5.log  rc4C.log
2a.log     la1e6.log  la3e6.log  lb2e6.log  lc1e6.log  lc3e6.log  rc5A.log
2b.log     la1e7.log  la3e7.log  lb2e7.log  lc1e7.log  lc3e7.log  rc5B.log
3a.log     la1e8.log  la3e8.log  lb2e8.log  lc1e8.log  lc3e8.log  rc5C.log
3b.log     la1e.log   la3e.log   lb2e.log   lc1e.log   lc3e.log   rc6A.log
4a.log     la2d5.log  lb1d5.log  lb3d5.log  lc2d5.log  rc         rc6B.log
4b.log     la2d6.log  lb1d6.log  lb3d6.log  lc2d6.log  rc0A.log   rc6C.log
5a.log     la2d7.log  lb1d7.log  lb3d7.log  lc2d7.log  rc0B.log   rc7A.log
5b.log     la2d8.log  lb1d8.log  lb3d8.log  lc2d8.log  rc0C.log   rc7B.log
6a.log     la2d.log   lb1d.log   lb3d.log   lc2d.log   rc1A.log   rc7C.log
6b.log     la2e5.log  lb1e5.log  lb3e5.log  lc2e5.log  rc1B.log   rc8A.log
7a.log     la2e6.log  lb1e6.log  lb3e6.log  lc2e6.log  rc1C.log   rc8B.log
7b.log     la2e7.log  lb1e7.log  lb3e7.log  lc2e7.log  rc2A.log   rc8C.log
8a.log     la2e8.log  lb1e8.log  lb3e8.log  lc2e8.log  rc2B.log   rc9A.log
8b.log     la2e.log   lb1e.log   lb3e.log   lc2e.log   rc2C.log   rc9B.log
la1d5.log  la3d5.log  lb2d5.log  lc1d5.log  lc3d5.log  rc3A.log   rc9C.log
la1d6.log  la3d6.log  lb2d6.log  lc1d6.log  lc3d6.log  rc3B.log
la1d7.log  la3d7.log  lb2d7.log  lc1d7.log  lc3d7.log  rc3C.log
la1d8.log  la3d8.log  lb2d8.log  lc1d8.log  lc3d8.log  rc4A.log

/etc/tmpfiles.d:

/etc/tuned:
active_profile  bootcmdline  profile_mode  recommend.d  tuned-main.conf

/etc/udev:
hwdb.bin  hwdb.d  rules.d  udev.conf

/etc/udisks2:
udisks2.conf

/etc/unbound:
icannbundle.pem  root.key

/etc/vmware-tools:
guestproxy-ssl.conf  resume-vm-default  suspend-vm-default
poweroff-vm-default  scripts            vgauth
poweron-vm-default   statechange.subr   vgauth.conf

/etc/X11:
applnk  fontpath.d  xinit  xorg.conf.d

/etc/xdg:
autostart  systemd

/etc/xinetd.d:
chargen-dgram   daytime-stream  echo-dgram     time-dgram
chargen-stream  discard-dgram   echo-stream    time-stream
daytime-dgram   discard-stream  tcpmux-server

/etc/yum:
pluginconf.d  protected.d  vars

/etc/yum.repos.d:
CentOS-AppStream.repo      CentOS-centosplus.repo  CentOS-HA.repo
CentOS-AppStream.repo.bac  CentOS-CR.repo          CentOS-Media.repo
CentOS-Base.repo           CentOS-Debuginfo.repo   CentOS-PowerTools.repo
CentOS-Base.repo.backup    CentOS-Extras.repo      CentOS-Sources.repo
CentOS-Base.repo.backup.3  CentOS-fasttrack.repo   CentOS-Vault.repo
* * * 胖并快乐着的死肥宅 * * *
posted @ 2021-03-04 10:53  白_胖_子  阅读(310)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3