linux学习命令总结⑥

#文件名通配

通配符:

*:匹配任意长度的任意字符(0到多个)

[[email protected]_168_102_centos ~]# ls *
0812080808

2014-05-16:
test.log

ceshi_1:

test:
[[email protected]_168_102_centos ~]# ls -ld t*
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test

?:匹配任意单个字符

[[email protected]_168_102_centos ~]# ls
0812080808  2014-05-16  ceshi_1  test
[[email protected]_168_102_centos ~]# ls tes?
[[email protected]_168_102_centos ~]# ls -ld tes?
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[[email protected]_168_102_centos ~]# ls -ld t?st
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[[email protected]_168_102_centos ~]# ls -ld t???
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[[email protected]_168_102_centos ~]# ls -ld t??
ls: cannot access t??: No such file or directory

[ ]:匹配指定字符范围内的任意单个字符

[[email protected]_168_102_centos ~]# ls -ld *[abc]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab
[[email protected]_168_102_centos ~]# ls -ld *[ac]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
[[email protected]_168_102_centos ~]# ls -ld [abc]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe

[a-z]:所有小写字母

[[email protected]_168_102_centos ~]# ls
ABC  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld *[a-z]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[[:lower:]]:所有小写字母

[[email protected]_168_102_centos ~]# ls -ld *[[:lower:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[A-Z]:所有大写字母

[[email protected]_168_102_centos ~]# ls
ABC  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld *[A-Z]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC

[[:upper:]]:所有大写字母

[[email protected]_168_102_centos ~]# ls -ld *[[:upper:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC

[[:alpha:]]:所有字母,不区分大小写

[[email protected]_168_102_centos ~]# ls -ld *[[:alpha:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[0-9]:所有数字

[[email protected]_168_102_centos ~]# ls
123  ABC  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld *[0-9]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
[[email protected]_168_102_centos ~]# ls -ld *[23]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123

[[digit:]]:所有数字

[[email protected]_168_102_centos ~]# ls -ld *[[:digit:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123

[[:alnum:]]:所有数字和字母,字母不分大小写

[[email protected]_168_102_centos ~]# ls -ld *[[:alnum:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[[:space:]]:空格

[[email protected]_168_102_centos ~]# ls
123  ABC  a c  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld *[[:space:]]
ls: cannot access *[[:space:]]: No such file or directory
[[email protected]_168_102_centos ~]# ls -ld *[[:space:]]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c

[[:punct:]]:标点符号

[[email protected]_168_102_centos ~]# ls
,,1  123  ABC  a c  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld [[:punct:]]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:16 ,,1

[^]:匹配指定字符范围外的任意单个字符

[^0-9]:除了数字

[[email protected]_168_102_centos ~]# ls
,,1  123  ABC  a c  abc  abd  abe  xab
[[email protected]_168_102_centos ~]# ls -ld *[^0-9]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[^[:upper:]]:除了大写字母

[[email protected]_168_102_centos ~]# ls -ld *[^[:upper:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:16 ,,1
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

linux学习命令总结⑥

时间: 2024-10-13 10:48:20

linux学习命令总结⑥的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组.在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置.普通用户不能将自己的文件改变成其他的属主.其操作权限一般为管理员. 修改文件属主和属组: [[email protected]_168_102_centos ~]# ls -l total 8 drwxr-xr-x 2 wanghan hx 4096 Aug 12 10:32 abe drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab [

linux学习命令总结⑨

#重定向 输出重定向: 1>覆盖输出(1可省略) [[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# ca

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录.文件夹.文件权限),查看目录信息等等 [[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot dev home lib64 media opt root selinux sys usr ls –a:显示所有文件,包含.开头的隐藏文件 [[email prot

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑩②

#fdisk命令:磁盘分区工具 fdisk –l:查看机器所挂硬盘个数及分区情况 [[email protected]_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8