如何递归删除子目录下的特定文件
find . -name '*.exe' -type f -print -exec rm -rf {} \;
(1) "." 表示从当前目录开始递归查找
(2) “ -name '*.exe' "根据名称来查找,要查找所有以.exe结尾的文件夹或者文件
(3) " -type f "查找的类型为文件
(4) "-print" 输出查找的文件目录名
(5) 最主要的是是-exec了,-exec选项后边跟着一个所要执行的命令,表示将find出来的文件或目录执行该命令。
exec选项后面跟随着所要执行的命令或脚本,然后是一对儿{},一个空格和一个\,最后是一个分号
排除模式cp文件
rsync -a test.svr test.svr3 --exclude=.svn
查看Linux内核版本
cat /proc/version
查看Linux硬件信息
[czf@localhost ~]$ cat /proc/cpuinfo |grep name | cut -f2 -d: |uniq -c
4 Intel(R) Xeon(R) CPU E5405 @ 2.00GHz
[czf@localhost ~]$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
258G 92G 154G 38% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
通配符知识
ls test*
匹配test+任意数量的任意字符,如:test1、test1234、testx、testxxxxx...
ls test?
匹配test+一个任意字符,如:testx、test3、testC ...
ls test[1-3]
匹配test+一个数字,数字范围1-3(含1和3),如:test1、test2、test3
或字母:test[a-c]
文件信息查看
1. stat:这个命令可以看到权限,时间,文件大小的信息;
2. du:主要看文件大小信息;
3. cat:查看文件内容信息;
4. file: 查看文件类型信息;
5. ls:文件查看的基本命令,相当于stat所列出文件信息的简化信息;
查看目录大小
du -h --max-depth=1 /home
文件搜索
查找大于1G的文件
find / -size +1G
查找大于1M的文件
find / -size +1M
-size n[cwbkMG]
File uses n units of space. The following suffixes can be used:
b for 512-byte blocks (this is the default if no suffix is used)
c for bytes
w for two-byte words
k for Kilobytes (units of 1024 bytes)
M for Megabytes (units of 1048576 bytes)
G for Gigabytes (units of 1073741824 bytes)
按文件大小排序查看文件
ll -h -S 从大到小
ll -h -S -r 从小到大
查找指定时间内的文件
mtime 文件内容上次修改时间
atime 文件被读取或访问的时间
ctime 文件状态变化时间
N * 24
+1 表示 1 * 24 +24小时以外..
+0 表示 0 * 24 +24小时以外
1 表示 1 * 24 + 24 到 24 之间..
0 表示 0 * 24 + 24 到 0 之间..
-1 表示 0 * 24 +24 内,甚至为未来时间...
1.当前时间24小时—当前时间(昨天-今天)
#find . -mtime 0
2.当前时间48小时前–当前时间24小时前(前天-昨天)
#find . -mtime 1
3.当前时间48小时前(2天前)
#find . -mtime +1
4.当前时间24小时–当前时间(昨天-今天)
#find . -mtime -1
弹出光驱
eject