一天一个命令,做个记录, 我要成大神,哈哈哈 本原创文章属于《Linux大棚》博客。 博客地址为http://roclinux.cn。 文章作者为roc 希望您能通过捐款的方式支持Linux大棚博客的运行和发展。请见关于捐款 == 先看例子,对find有个大致的了解,最后作总结(如
一天一个命令,做个记录,
我要成大神,哈哈哈
本原创文章属于《Linux大棚》博客。
博客地址为http://roclinux.cn。
文章作者为roc
希望您能通过捐款的方式支持Linux大棚博客的运行和发展。请见“关于捐款”
==
先看例子,对find有个大致的了解,最后作总结(如果你只想温习,可以直接到最后看总结)
1. 想查看当前文件夹及子文件夹里有没有文件名为“abc”的文件(不是目录)
# find . -name abc
. :表示当前目录
-name:表示要根据名称查找
2. 想查看当前文件夹及子文件夹里有没有”xyz”目录
# find . -type d -name xyz (d前没有-)
-type:表示设定类型,d表示文件夹类型,可以替换为f(普通文件)、l(链接文件)
3. 想找出当前文件夹及子文件夹里所有后缀是”.txt”的文件
# find . -name “*.txt”
跟1类似,不过-name的参数成了一个模式,而不再是具体的文件名
4. 想查找当前目录及其子文件夹中“roc”用户自己的文件有哪些
# find . -user roc
-user:用于设定所属用户的名称,此处可替换为-group,即所属用户组的名称
5. 想查找当前文件夹及子文件夹里权限设定为755的所有文件
# find . -perm 755
-perm:用于设定权限
6. 想查找当前文件夹及子文件夹里的同时含有b字符和3字符的文件:用到正则表达式技术
# find . -regex ‘.*b.*3′
-regex:表示使用正则表达式进行匹配。请注意,此命令会和“全路径”进行匹配,也就是说前面要加.*,因为输出结果中会有“./”符号。
7. 如果想全部输出用find命令查找出的”*.abc”文件的内容
# find . -type f -name “*.abc” -exec cat {} \;
-exec 表示由find找到的匹配项会作为“-exec后面设定的命令”的参数
可以使用-ok代替-exec,这样对每个匹配项进行操作,都会要求用户确认(y为是,n为否)
命令最后的{} \; 别忘了写,其中{}代表用find查找到的结果中的每一个查找项。
8. 查找当前目录下在5分钟内被访问过的文件
# find . -amin -5
访问过用amin,修改过用mmin,文件状态改变过用cmin
精确到分钟的用amin,mmin,cmin,精确到天的用atime,mtime,ctime
在5分钟之内的用-5,在5分钟以上的用+5
9. 想查找当前目录及子目录下文件大小大于10M的所有文件
# find . -size +10000000c
-size:表示文件大小,+表示大于某个数,-表示小于某个数。c表示单位是字节,你可以将c换成k,M,G。
10. 上述所有的find命令都是查找当前目录及其子目录。如果不想深入到子目录中,而是只查找当前一层目录,则可以:
# find . -maxdepth 1 -name “*.c”
总结:
通过上面的例子,我们已经初识了find。升一个层次。
1 find的命令格式
find pathname -options filename [-print,-exec,-ok [command {} \;]]
2 命令功能
用于在文件树中的查找文件
3 命令参数:
pathname: find命令所查找的目录路径。例如用.来表示当前目录,用/来表示系统根目录。
-print: find命令将匹配的文件输出到标准输出。
-exec: find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为command { } \;,注意{ }和\;之间的空格。
-ok: 和-exec的作用相同,只不过以一种更为安全的模式来执行该参数所给出的shell命令,在执行每一个命令之前,都会给出提示,让用户来确定是否执行。
4 option选项
依据文件名
-name :支持“*”匹配符,需要使用正则则用-regex
依据文件大小
-size: -size n[c,K,M,G],注意k是小写,大写是错误的。可以指定一个范围,如-size -10M -size + 5M ,表示 5M
依据文件类型
-type: 后接d(目录),f(普通文件),p(管道文件),b(块设备),l(链接文件),s(socket文件)
依据时间:
访问:-amin,-atime
修改:-mmin,-mtime
状态变化:-cmin,-ctime
依据属主身份;
所属主:-user,-nouser
所属组:-group,-nogroup
依据权限:
-perm
其他:
-depth:在查找文件时,首先查找当前目录中的文件,然后再在其子目录中查找。
-newer file1 ! file2 查找更改时间比文件file1新但比文件file2旧的文件。
-fstype:查找位于某一类型文件系统中的文件,这些文件系统类型通常可以在配置文件/etc/fstab中找到,该配置文件中包含了本系统中有关文件系统的信息。
-mount:在查找文件时不跨越文件系统mount点。
-follow:如果find命令遇到符号链接文件,就跟踪至链接所指向的文件。
-cpio:对匹配的文件使用cpio命令,将这些文件备份到磁带设备中。
各选项可以一起使用

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment
